Skip to content

Commit 80fa4cd

Browse files
feat: prompt user to build fe at first run (#9381)
When `marimo edit` is run from a repo checkout without built frontend assets, the current error is `index.html not found and no asset_url configured`, which is confusing for contributors. This changes that path to return a more actionable message telling the user to run `make fe` and restart marimo. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 3687c76 commit 80fa4cd

2 files changed

Lines changed: 39 additions & 1 deletion

File tree

marimo/_server/api/endpoints/assets.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,18 @@
6767
follow_symlinks = server_config.get("follow_symlink", False)
6868

6969

70+
def _missing_index_html_detail() -> str:
71+
repo_root = marimo_package_path().parent
72+
if (repo_root / "frontend").exists() and (
73+
repo_root / "pyproject.toml"
74+
).exists():
75+
return (
76+
"index.html not found. Did you run `make fe`? "
77+
"Restart marimo after building."
78+
)
79+
return "index.html not found and no asset_url configured"
80+
81+
7082
def _has_symlinks(directory: Path) -> bool:
7183
"""Check if a directory is a symlink or contains symlinked files."""
7284
if directory.is_symlink():
@@ -316,7 +328,7 @@ async def index(request: Request) -> Response:
316328
else:
317329
raise HTTPException(
318330
status_code=500,
319-
detail="index.html not found and no asset_url configured",
331+
detail=_missing_index_html_detail(),
320332
)
321333

322334
if not file_key:

tests/_server/api/endpoints/test_assets.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,32 @@ def test_index_when_new_file(client: TestClient) -> None:
8383
assert "<title>marimo</title>" in content
8484

8585

86+
def test_index_missing_assets_in_source_checkout_shows_build_hint(
87+
client: TestClient, tmp_path: Path
88+
) -> None:
89+
source_root = tmp_path / "repo"
90+
source_root.mkdir()
91+
(source_root / "frontend").mkdir()
92+
(source_root / "pyproject.toml").write_text("")
93+
94+
missing_static_root = tmp_path / "missing_static"
95+
missing_static_root.mkdir()
96+
97+
with (
98+
patch("marimo._server.api.endpoints.assets.root", missing_static_root),
99+
patch(
100+
"marimo._server.api.endpoints.assets.marimo_package_path",
101+
return_value=source_root / "marimo",
102+
),
103+
):
104+
response = client.get("/", headers=token_header())
105+
106+
assert response.status_code == 500
107+
detail = response.json()["detail"]
108+
assert "Did you run `make fe`?" in detail
109+
assert "Restart marimo after building." in detail
110+
111+
86112
def test_index_strips_access_token_query_param(client: TestClient) -> None:
87113
# A valid `?access_token=` in the URL should 303 to the same path with
88114
# the token removed, carrying a session cookie so the follow-up request

0 commit comments

Comments
 (0)