From 2093f02cdd81ee90baa93d3a1d55aa573b4814eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ralph=20K=C3=BCpper?= Date: Fri, 25 Sep 2026 16:02:00 +0200 Subject: [PATCH 1/2] fix(build): read CARGO_MANIFEST_DIR at build-script run time crates/perry/build/android_template.rs used env!("CARGO_MANIFEST_DIR"), which bakes the path in when the build script is compiled. Cargo reuses a compiled build script across checkouts that share a target dir, so the baked path points at whichever checkout compiled it; once that worktree is deleted every later build panics at build.rs:5 (read_dir on a missing directory). Read the variable at run time, where cargo sets it for the package being built. --- crates/perry/build/android_template.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/perry/build/android_template.rs b/crates/perry/build/android_template.rs index 4f82840216..1605d2c670 100644 --- a/crates/perry/build/android_template.rs +++ b/crates/perry/build/android_template.rs @@ -2,7 +2,12 @@ use std::{env, fs, io, path::Path}; pub fn emit() -> io::Result<()> { - let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../perry-ui-android/template"); + // Read the manifest dir at build-script RUN time, not via `env!` at its + // compile time: cargo reuses a compiled build script across checkouts that + // share a target dir, and a baked-in path points at whichever checkout + // compiled it (a deleted worktree then panics every later build). + let manifest_dir = env::var_os("CARGO_MANIFEST_DIR").expect("cargo sets CARGO_MANIFEST_DIR"); + let root = Path::new(&manifest_dir).join("../perry-ui-android/template"); let mut files = Vec::new(); collect(&root, &root, &mut files)?; files.sort(); From 8f93ff338aff1bd7c3003f98417f1d979436c99c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ralph=20K=C3=BCpper?= Date: Fri, 25 Sep 2026 16:02:17 +0200 Subject: [PATCH 2/2] changelog: fragment for #11330 --- changelog.d/11330-build-script-runtime-manifest-dir.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/11330-build-script-runtime-manifest-dir.md diff --git a/changelog.d/11330-build-script-runtime-manifest-dir.md b/changelog.d/11330-build-script-runtime-manifest-dir.md new file mode 100644 index 0000000000..62f87d7d2f --- /dev/null +++ b/changelog.d/11330-build-script-runtime-manifest-dir.md @@ -0,0 +1 @@ +**fix(build): read `CARGO_MANIFEST_DIR` at build-script run time.** `crates/perry/build/android_template.rs` used `env!("CARGO_MANIFEST_DIR")`, which bakes the path in when the build script is compiled. Cargo reuses a compiled build script across checkouts that share a target directory, so after the checkout that compiled it was deleted, every later build panicked at `build.rs:5`. The build script now reads the variable at run time.