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.

feat: prompt user to build fe at first run (#9381)

ouatu-ro80fa4cdc4c5d
diff --git a/marimo/_server/api/endpoints/assets.py b/marimo/_server/api/endpoints/assets.py
index 4853207130..3d9d1783cd 100644
--- a/marimo/_server/api/endpoints/assets.py
+++ b/marimo/_server/api/endpoints/assets.py
@@ -67,6 +67,18 @@ assets_dir = root / "assets"
follow_symlinks = server_config.get("follow_symlink", False)
+def _missing_index_html_detail() -> str:
+ repo_root = marimo_package_path().parent
+ if (repo_root / "frontend").exists() and (
+ repo_root / "pyproject.toml"
+ ).exists():
+ return (
+ "index.html not found. Did you run `make fe`? "
+ "Restart marimo after building."
+ )
+ return "index.html not found and no asset_url configured"
+
+
def _has_symlinks(directory: Path) -> bool:
"""Check if a directory is a symlink or contains symlinked files."""
if directory.is_symlink():
@@ -316,7 +328,7 @@ async def index(request: Request) -> Response:
else:
raise HTTPException(
status_code=500,
- detail="index.html not found and no asset_url configured",
+ detail=_missing_index_html_detail(),
)
if not file_key:
diff --git a/tests/_server/api/endpoints/test_assets.py b/tests/_server/api/endpoints/test_assets.py
index 1ba4a7e368..dddff1d7b5 100644
--- a/tests/_server/api/endpoints/test_assets.py
+++ b/tests/_server/api/endpoints/test_assets.py
@@ -83,6 +83,32 @@ def test_index_when_new_file(client: TestClient) -> None:
assert "<title>marimo</title>" in content
+def test_index_missing_assets_in_source_checkout_shows_build_hint(
+ client: TestClient, tmp_path: Path
+) -> None:
+ source_root = tmp_path / "repo"
+ source_root.mkdir()
+ (source_root / "frontend").mkdir()
+ (source_root / "pyproject.toml").write_text("")
+
+ missing_static_root = tmp_path / "missing_static"
+ missing_static_root.mkdir()
+
+ with (
+ patch("marimo._server.api.endpoints.assets.root", missing_static_root),
+ patch(
+ "marimo._server.api.endpoints.assets.marimo_package_path",
+ return_value=source_root / "marimo",
+ ),
+ ):
+ response = client.get("/", headers=token_header())
+
+ assert response.status_code == 500
+ detail = response.json()["detail"]
+ assert "Did you run `make fe`?" in detail
+ assert "Restart marimo after building." in detail
+
+
def test_index_strips_access_token_query_param(client: TestClient) -> None:
# A valid `?access_token=` in the URL should 303 to the same path with
# the token removed, carrying a session cookie so the follow-up request