From 2ea3da4819c1ac5f483f09594fab6b95237c1a1b Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sun, 23 Nov 2025 10:07:25 +0100 Subject: [PATCH] config_paths: disable the relocatable tree logic on Cargo builds This only makes sense for builds that install directories like $PREFIX/share/fish, $PREFIX/etc/fish. --- src/env/config_paths.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/env/config_paths.rs b/src/env/config_paths.rs index 7e0984123..969d58224 100644 --- a/src/env/config_paths.rs +++ b/src/env/config_paths.rs @@ -102,7 +102,7 @@ fn from_exec_path(unresolved_exec_path: &'static FishPath) -> Self { let workspace_root = workspace_root(); // TODO(MSRV>=1.88): if-let-chain - if exec_path_parent.ends_with("bin") && { + if cfg!(using_cmake) && exec_path_parent.ends_with("bin") && { let prefix = exec_path_parent.parent().unwrap(); let data = prefix.join("share/fish"); let sysconf = prefix.join("etc/fish"); @@ -112,6 +112,7 @@ fn from_exec_path(unresolved_exec_path: &'static FishPath) -> Self { // Installing somewhere else inside the workspace is fine. && prefix != workspace_root } { + const _: () = assert!(!cfg!(using_cmake) || DOC_DIR.is_some()); FLOG!(config, "Running from relocatable tree"); let prefix = exec_path_parent.parent().unwrap(); Self { @@ -120,11 +121,11 @@ fn from_exec_path(unresolved_exec_path: &'static FishPath) -> Self { data: Some(prefix.join("share/fish")), doc: { let doc = prefix.join("share/doc/fish"); - if doc.exists() { - Some(doc) + Some(if doc.exists() { + doc } else { - DOC_DIR.map(PathBuf::from) - } + PathBuf::from(DOC_DIR.unwrap()) + }) }, } } else if exec_path.starts_with(BUILD_DIR) {