From b83800ba5a3826dfa5de690d04a2673d4d197ef2 Mon Sep 17 00:00:00 2001 From: Sylvain Bellemare Date: Tue, 17 Mar 2026 23:08:58 +0900 Subject: [PATCH] fix: use runtime CARGO_MANIFEST_DIR Problem: env!() bakes the path at compile time, so it breaks when the binary runs from a different location (e.g. a Guix/Nix sandbox or container). Solution: use std::env::var() to read it at runtime. --- locales/build.rs | 2 +- xtask/src/builder.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/locales/build.rs b/locales/build.rs index dfcfb1056..f7dcf5539 100644 --- a/locales/build.rs +++ b/locales/build.rs @@ -144,5 +144,5 @@ fn main() { } fn project_root() -> PathBuf { - Path::new(&env!("CARGO_MANIFEST_DIR")).ancestors().nth(1).unwrap().to_path_buf() + Path::new(&std::env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set — this binary must be run via cargo")).ancestors().nth(1).unwrap().to_path_buf() } diff --git a/xtask/src/builder.rs b/xtask/src/builder.rs index e0fc8fcba..d36860342 100644 --- a/xtask/src/builder.rs +++ b/xtask/src/builder.rs @@ -1511,7 +1511,7 @@ impl Builder { pub fn cargo() -> String { env::var("CARGO").unwrap_or_else(|_| "cargo".to_string()) } pub fn project_root() -> PathBuf { - Path::new(&env!("CARGO_MANIFEST_DIR")).ancestors().nth(1).unwrap().to_path_buf() + Path::new(&std::env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set — this binary must be run via cargo")).ancestors().nth(1).unwrap().to_path_buf() } use std::fs::File;