diff --git a/fish-rust/src/env/environment.rs b/fish-rust/src/env/environment.rs index a5ea48225..3e75cd0fa 100644 --- a/fish-rust/src/env/environment.rs +++ b/fish-rust/src/env/environment.rs @@ -512,7 +512,7 @@ fn setup_path() { str2wcstring(cstr.to_bytes()) } else { // the above should really not fail - L!("/usr/bin:/bin").to_owned() + join_strings(crate::path::DEFAULT_PATH.as_ref(), ':') }; vars.set_one(L!("PATH"), EnvMode::GLOBAL | EnvMode::EXPORT, path); diff --git a/fish-rust/src/path.rs b/fish-rust/src/path.rs index 70607e680..81595f624 100644 --- a/fish-rust/src/path.rs +++ b/fish-rust/src/path.rs @@ -185,7 +185,7 @@ pub fn path_get_path(cmd: &wstr, vars: &dyn Environment) -> Option { // PREFIX is defined at build time. #[widestrs] -static DEFAULT_PATH: Lazy<[WString; 3]> = Lazy::new(|| { +pub static DEFAULT_PATH: Lazy<[WString; 3]> = Lazy::new(|| { [ // TODO This should use env!. The fallback is only to appease "cargo test" for now. WString::from_str(option_env!("PREFIX").unwrap_or("/usr/local")) + "/bin"L, diff --git a/tests/checks/default-setup-path.fish b/tests/checks/default-setup-path.fish index 8f693ade5..739b74167 100644 --- a/tests/checks/default-setup-path.fish +++ b/tests/checks/default-setup-path.fish @@ -6,6 +6,7 @@ if command -q getconf env -u PATH $fish -c 'test "$PATH" = "$('(command -s getconf)' PATH)"; and echo Success' else # this is DEFAULT_PATH - env -u PATH $fish -c 'test "$PATH" = "/usr/bin:/bin"; and echo Success' + # the first element (usually `/usr/local/bin`) depends on PREFIX set in CMake, so we ignore it + env -u PATH $fish -c 'test "$PATH[2..]" = "/usr/bin:/bin"; and echo Success' end # CHECK: Success