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

- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
- 🟢 `toolkit test`
- 🟢 `toolkit test stdlib`

# After Submitting

N/A
This commit is contained in:
Douglas 2025-01-20 17:49:07 -05:00 committed by GitHub
parent ee84435a0e
commit b97d89adb6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -350,12 +350,6 @@ pub fn get_vendor_autoload_dirs(_engine_state: &EngineState) -> Vec<PathBuf> {
pub fn get_user_autoload_dirs(_engine_state: &EngineState) -> Vec<PathBuf> {
// 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<PathBuf> {
}
};
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