Summary
When mobuild.runtime_sync() runs in a notebook that is outside of mobuild, it attempts to _write_file where the file parameter (i.e. input file) resolves to the path of mobuild/init.py rather than to the current notebook.
This causes a crash because mobuild's ._app is a Typer app rather than a Marimo notebook.
Reproduction

Expected behavior
The notebook's exported cells (those marked with ## EXPORT) are written to src/package_name.
Actual behavior
File ".../mobuild/__init__.py", line 132, in runtime_sync
_write_file(Path(__file__), output_path)
File ".../mobuild/__init__.py", line 75, in _write_file
order = internal.execution_order
File ".../marimo/_ast/app.py", line 971, in execution_order
self._app._maybe_initialize()
AttributeError: 'Typer' object has no attribute '_maybe_initialize'
Root cause
In mobuild/__init__.py:132, Path(__file__) resolves to mobuild's own __init__.py (because __file__ in any function refers to the module that defines the function, not the caller). _write_file then:
- Imports
mobuild/__init__.py as a "notebook".
- Grabs its module-level
app — which is typer.Typer(no_args_is_help=True) from line 12.
- Wraps it in
InternalApp and accesses .execution_order, which calls _maybe_initialize() on the Typer object → AttributeError.
Suggested fix
runtime_sync needs to discover the caller's file, e.g. via inspect.stack()[1].filename or by accepting the notebook path as an argument, then pass that to _write_file.
Attribution
Diagnosis and reproducible example by Claude Opus 4.7 with minimal edits to the explanation by me.
Summary
When mobuild.runtime_sync() runs in a notebook that is outside of mobuild, it attempts to _write_file where the file parameter (i.e. input file) resolves to the path of mobuild/init.py rather than to the current notebook.
This causes a crash because mobuild's ._app is a Typer app rather than a Marimo notebook.
Reproduction
Expected behavior
The notebook's exported cells (those marked with
## EXPORT) are written tosrc/package_name.Actual behavior
Root cause
In
mobuild/__init__.py:132,Path(__file__)resolves to mobuild's own__init__.py(because__file__in any function refers to the module that defines the function, not the caller)._write_filethen:mobuild/__init__.pyas a "notebook".app— which istyper.Typer(no_args_is_help=True)from line 12.InternalAppand accesses.execution_order, which calls_maybe_initialize()on theTyperobject →AttributeError.Suggested fix
runtime_syncneeds to discover the caller's file, e.g. viainspect.stack()[1].filenameor by accepting the notebook path as an argument, then pass that to_write_file.Attribution
Diagnosis and reproducible example by Claude Opus 4.7 with minimal edits to the explanation by me.