From b97d89adb6c13122dd2539f9ab93623d8d9e81e8 Mon Sep 17 00:00:00 2001 From: Douglas <32344964+NotTheDr01ds@users.noreply.github.com> Date: Mon, 20 Jan 2025 17:49:07 -0500 Subject: [PATCH] Fix retrieval of config directory for user autoloads (#14877) # Description Fixes an issue with #14669 - I mistakenly used `dirs::config_dir()` when it should be `nu_path::config_dir()`. This allows `XDG_CONFIG_DIR` to specify the location properly. # User-Facing Changes Fix: If `XDG_CONFIG_DIR` is set, it will be used for the `autoload` location. # Tests + Formatting - :green_circle: `toolkit fmt` - :green_circle: `toolkit clippy` - :green_circle: `toolkit test` - :green_circle: `toolkit test stdlib` # After Submitting N/A --- crates/nu-protocol/src/eval_const.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/crates/nu-protocol/src/eval_const.rs b/crates/nu-protocol/src/eval_const.rs index 42bf6b4de6..b6506a7151 100644 --- a/crates/nu-protocol/src/eval_const.rs +++ b/crates/nu-protocol/src/eval_const.rs @@ -350,12 +350,6 @@ pub fn get_vendor_autoload_dirs(_engine_state: &EngineState) -> Vec { pub fn get_user_autoload_dirs(_engine_state: &EngineState) -> Vec { // User autoload directories - Currently just `autoload` in the default // configuration directory - let into_autoload_path_fn = |mut path: PathBuf| { - path.push("nushell"); - path.push("autoload"); - path - }; - let mut dirs = Vec::new(); let mut append_fn = |path: PathBuf| { @@ -364,8 +358,8 @@ pub fn get_user_autoload_dirs(_engine_state: &EngineState) -> Vec { } }; - if let Some(config_dir) = dirs::config_dir() { - append_fn(into_autoload_path_fn(config_dir)); + if let Some(config_dir) = nu_path::nu_config_dir() { + append_fn(config_dir.join("autoload").into()); } dirs