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;