From a59ba4af1b917bbd062d8c7bfea9ddc6b73fea73 Mon Sep 17 00:00:00 2001 From: Nils Pukropp Date: Wed, 21 Oct 2026 12:35:59 +0200 Subject: [PATCH] build: a clone compiles before the frontend is built rust-embed refused to derive without `web/dist`, so on a fresh clone `cargo check`, `cargo test` and rust-analyzer failed with a derive error that did not say what was missing. With `allow_missing` the embed is empty until the frontend is built, and the handler gives the answer it already had for that case, "frontend not built". The release build is unchanged once `web/dist` is there, which `make build`, the Dockerfile and CI all see to. --- .github/workflows/ci.yml | 2 +- README.md | 4 ++-- docs/wiki/Development.md | 12 +++++++----- src/static_files.rs | 5 ++++- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 931c845..5324f1b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: steps: - uses: actions/checkout@v4 - uses: oven-sh/setup-bun@v2 - # The binary embeds web/dist, so nothing compiles before the frontend is built. + # Built first so the binary under test embeds the app it ships with. - name: frontend working-directory: web run: | diff --git a/README.md b/README.md index 8474841..1f9edef 100644 --- a/README.md +++ b/README.md @@ -91,8 +91,8 @@ make dev-web # vite dev server on :4243, proxying /api to :4242 ``` In debug builds the binary reads `web/dist` from disk, so `cargo run` alone also -works once the frontend has been built at least once — and not before: the -binary embeds `web/dist`, so a fresh clone builds the frontend first. +works once the frontend has been built at least once. Before that it compiles, +tests and runs the API, and answers every page with "frontend not built". `make check` runs what CI runs: format, clippy, the tests, svelte-check, and a check that the generated wiki pages are current. The wiki is written in diff --git a/docs/wiki/Development.md b/docs/wiki/Development.md index 098b82a..e91aeab 100644 --- a/docs/wiki/Development.md +++ b/docs/wiki/Development.md @@ -7,9 +7,11 @@ make dev-api # cargo run, serving the API on :4242 make dev-web # vite on :4243, proxying /api to :4242 ``` -Open . The Rust build embeds `web/dist`, so build the -frontend once (`cd web && bun install && bun run build`) before the first -`cargo build`; a debug build reads `web/dist` from disk after that. +Open . The release binary embeds `web/dist`, and a +debug build reads it from disk, so build the frontend once +(`cd web && bun install && bun run build`) for `cargo run` alone to serve the +app. Without it the Rust side still compiles and tests, and the pages answer +"frontend not built". Point `WORKSPACE_DATA_DIR` at a throwaway directory while trying things, so the real data stays out of it. @@ -57,8 +59,8 @@ block at the bottom. `.github/workflows/ci.yml` runs on every push and pull request: -- **rust**: builds the frontend (the binary embeds it), then format, clippy - and the tests; +- **rust**: builds the frontend, so the tests see the app the binary ships, + then format, clippy and the tests; - **web**: svelte-check; - **docs**: checks that the generated wiki pages are up to date and that every link between the pages resolves. diff --git a/src/static_files.rs b/src/static_files.rs index a3ad0c7..98a9c70 100644 --- a/src/static_files.rs +++ b/src/static_files.rs @@ -5,9 +5,12 @@ use axum::{ use rust_embed::Embed; /// The built Svelte app. In debug builds rust-embed reads from disk, so a -/// `vite build --watch` next to `cargo run` is enough for iteration. +/// `vite build --watch` next to `cargo run` is enough for iteration. A clone +/// that has not built the frontend yet still compiles, tests and checks; it +/// serves the "frontend not built" answer below until it has. #[derive(Embed)] #[folder = "$CARGO_MANIFEST_DIR/web/dist"] +#[allow_missing = true] struct Assets; pub async fn handler(uri: Uri) -> Response {