fix(build): read CARGO_MANIFEST_DIR at run time in build scripts

Merged
TE
4d ago
+8-2

Two build scripts read their own crate folder with the compile-time env!("CARGO_MANIFEST_DIR"). When a build cache reuses a build script binary compiled in another checkout, that path points into the old checkout:

  • cmux-browser-host/build.rs panics reading a js/manifest.json that no longer exists. This broke a chat-open benchmark build on a fleet worker: the step read …/steps/<old step>/src/cmux-tui/crates/cmux-browser-host/js/manifest.json while the source was in another slot.
  • cmux-tailnet/build.rs reads patches/ with unwrap_or_default, so it silently builds with no patches.

Both now read CARGO_MANIFEST_DIR at run time; Cargo sets it for every build script run. No other build.rs uses env!("CARGO_MANIFEST_DIR").

Small change: two lines of logic in two build scripts. Risk: none beyond the build itself; the variable is always set when Cargo runs a build script.

Agent session: agent session

🤖 Generated with Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.


Summary by cubic

Fixes build script caching failures by reading CARGO_MANIFEST_DIR at run time instead of compile time in two build scripts. When a cached build script binary is reused from a different checkout, env! keeps the old checkout's path; cmux-browser-host then panics on a missing js/manifest.json, and cmux-tailnet silently builds without its patches.