Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

fix: stop serving duplicate notebooks when `auto_download` is set (#8462)

Péter Gyarmati1ec69f99d6a5
diff --git a/marimo/_cli/cli.py b/marimo/_cli/cli.py
index dfb80512de..79d90f7ff3 100644
--- a/marimo/_cli/cli.py
+++ b/marimo/_cli/cli.py
@@ -841,6 +841,8 @@ def _collect_marimo_files(paths: list[str]) -> _CollectedRunFiles:
for file_info in flatten_files(file_infos):
if not file_info.is_marimo_file:
continue
+ if "__marimo__" in Path(file_info.path).parts:
+ continue
absolute_path = str(directory / file_info.path)
files_by_path[absolute_path] = MarimoFile(
name=file_info.name,
diff --git a/tests/_cli/test_cli.py b/tests/_cli/test_cli.py
index 58b2b3b64d..74459653fa 100644
--- a/tests/_cli/test_cli.py
+++ b/tests/_cli/test_cli.py
@@ -852,6 +852,30 @@ def test_collect_marimo_files_includes_markdown(
assert str(md_file) in {file.path for file in collected.files}
+def test_collect_marimo_files_excludes_marimo_generated_markdown(
+ tmp_path: Path,
+) -> None:
+ py_file = tmp_path / "notebook.py"
+ py_file.write_text("import marimo\napp = marimo.App()\n", encoding="utf-8")
+
+ md_file = tmp_path / "notes.md"
+ md_file.write_text("---\nmarimo-version: 0.1.0\n---\n", encoding="utf-8")
+
+ marimo_dir = tmp_path / "__marimo__"
+ marimo_dir.mkdir()
+ generated_md = marimo_dir / "notebook.md"
+ generated_md.write_text(
+ "---\nmarimo-version: 0.1.0\n---\n", encoding="utf-8"
+ )
+
+ collected = _collect_marimo_files([str(tmp_path)])
+ paths = {file.path for file in collected.files}
+
+ assert str(py_file) in paths
+ assert str(md_file) in paths
+ assert str(generated_md) not in paths
+
+
def test_cli_run_with_show_code(temp_marimo_file: str) -> None:
port = _get_port()
p = subprocess.Popen(