mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-22 03:51:15 -03:00
config_paths: fix compiled-in locale dir
Fish uses this logic to find paths to functions etc.: 1. if $(status fish-path) starts with $CARGO_MANIFEST_DIR, we use $CARGO_MANIFEST_DIR/share etc. Aside: this also has the unintended effect that "cmake -DCMAKE_INSTALL_PREFIX=$PWD/prefix" will not use "$PWD/prefix/share" but "$PWD/share", at least sinceeacbd6156d(Port and adopt main written in Rust, 2023-08-18). 2. Else if $(status fish-path) ends with "bin/fish", and $(status fish-path)/../share/fish exists, we use that, since4912967eab(Large set of changes related to making fish relocatable, and improving the build and install story, 2012-07-08) 3. Else if $(status fish-path) ends in "fish" (which is very likely), and $(status fish-path)/share exists, we use that, sincec2a8de4873(Make fish find config directories in source tree, 2016-09-23). I think this is for running (without installing) in-tree builds ("cmake ."); this is not recommended but it is used, see https://github.com/fish-shell/fish-shell/pull/10330 4. If none of the above worked, either because the fish binary has been moved into a weird directory, or if we fail to get $(status fish-path) (e.g. on OpenBSD, where "argv[0]" is not available), then we fall back to reasonable default paths determined at compiled time. These paths include data_dir=$PREFIX/share. We recently added locale_dir too inbf65b9e3a7(Change `gettext` paths to be relocatable (#11195), 2025-03-30). In case 1, we use locale: manifest_dir.join("share/locale"), In case 2 and 3, we use locale: data_dir.join("locale"), In case 4, we use locale: data_dir.join("share"), The last one seems wrong (there is not "/usr/share/share"). Fix that. Alternatively, we could revertbf65b9e3a7(and redo the parts we want to keep).
This commit is contained in:
8
src/env/config_paths.rs
vendored
8
src/env/config_paths.rs
vendored
@@ -7,6 +7,7 @@
|
||||
const DATA_DIR: &str = env!("DATADIR");
|
||||
const DATA_DIR_SUBDIR: &str = env!("DATADIR_SUBDIR");
|
||||
const SYSCONF_DIR: &str = env!("SYSCONFDIR");
|
||||
const LOCALE_DIR: &str = env!("LOCALEDIR");
|
||||
const BIN_DIR: &str = env!("BINDIR");
|
||||
|
||||
pub static CONFIG_PATHS: Lazy<ConfigPaths> = Lazy::new(|| {
|
||||
@@ -108,6 +109,11 @@
|
||||
} else {
|
||||
Some(PathBuf::from(BIN_DIR))
|
||||
};
|
||||
let locale = if cfg!(feature = "embed-data") {
|
||||
None
|
||||
} else {
|
||||
Some(PathBuf::from(LOCALE_DIR))
|
||||
};
|
||||
|
||||
FLOG!(config, "Using compiled in paths:");
|
||||
paths = ConfigPaths {
|
||||
@@ -115,7 +121,7 @@
|
||||
sysconf: PathBuf::from(SYSCONF_DIR).join("fish"),
|
||||
doc: DOC_DIR.into(),
|
||||
bin,
|
||||
locale: data.map(|x| x.join("share")),
|
||||
locale,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user