Skip to content

Build: the ui-egui build script reads CARGO_MANIFEST_DIR when it runs - #488

Merged
aiongg merged 1 commit into
storytold:mainfrom
prxnvt:pr/build-script-path
Oct 22, 2026
Merged

aiongg merged 1 commit into
storytold:mainfrom
prxnvt:pr/build-script-path

Conversation

@prxnvt

@prxnvt prxnvt commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

crates/ui-egui/build.rs locates contributors/ with env!("CARGO_MANIFEST_DIR"). The env! macro fixes the path when the build script itself is compiled, not when it runs. If a checkout is moved or copied after the first build, for example into another directory or a Git worktree that reuses a shared target directory, the compiled build script keeps reading the old location. Two effects follow:

  1. The About window shows no contributors, because contributors.json and people.toml are not found.
  2. The rerun-if-changed paths point at files that no longer exist, so Cargo reruns the build script, and therefore rebuilds gridcraft-ui-egui, on every build.

Change

The build script now reads CARGO_MANIFEST_DIR from its environment with std::env::var_os when it runs. Cargo sets this variable for every build-script run, so the path always follows the current checkout. The behaviour is otherwise unchanged.

Testing

  • cargo fmt --check, cargo clippy -p gridcraft-ui-egui --all-targets -D warnings and cargo xtask wasm pass.
  • The change is limited to how the path is obtained; the files read and the rerun-if-changed lines are the same as before.

Generative AI use: The code and descriptions in this pull request were written with the assistance of Claude Opus 5.5 (Claude Code). I directed the work, chose its scope, and reviewed and tested the changes.

env! fixes the path to contributors/ when the build script is compiled.
After a checkout is moved or copied, the compiled script keeps looking in
the old location: the About window loses its contributor list, and
because the rerun-if-changed path no longer exists, Cargo reruns the
script and rebuilds the UI crate on every build. Reading the variable at
run time follows the checkout.
@aiongg
aiongg merged commit 307b25d into storytold:main Oct 22, 2026
@prxnvt
prxnvt deleted the pr/build-script-path branch November 2, 2026 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants