mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
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.
This commit is contained in:
parent
e9c408fbca
commit
b83800ba5a
2 changed files with 2 additions and 2 deletions
|
|
@ -144,5 +144,5 @@ fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn project_root() -> PathBuf {
|
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()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1511,7 +1511,7 @@ impl Builder {
|
||||||
pub fn cargo() -> String { env::var("CARGO").unwrap_or_else(|_| "cargo".to_string()) }
|
pub fn cargo() -> String { env::var("CARGO").unwrap_or_else(|_| "cargo".to_string()) }
|
||||||
|
|
||||||
pub fn project_root() -> PathBuf {
|
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;
|
use std::fs::File;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue