Skip to content

Commit 45d33e7

Browse files
authored
Change NU_LIB_DIRS not to depend on $nu.config-path (#8887)
1 parent 9b35d59 commit 45d33e7

3 files changed

Lines changed: 22 additions & 4 deletions

File tree

crates/nu-cli/tests/completions.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,11 +524,12 @@ fn variables_completions() {
524524
// Test completions for $nu
525525
let suggestions = completer.complete("$nu.", 4);
526526

527-
assert_eq!(13, suggestions.len());
527+
assert_eq!(14, suggestions.len());
528528

529529
let expected: Vec<String> = vec![
530530
"config-path".into(),
531531
"current-exe".into(),
532+
"default-config-dir".into(),
532533
"env-path".into(),
533534
"history-path".into(),
534535
"home-path".into(),

crates/nu-engine/src/nu_variable.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,13 @@ pub struct NuVariable {
2525

2626
impl LazyRecord for NuVariable {
2727
fn column_names(&self) -> Vec<&'static str> {
28-
let mut cols = vec!["config-path", "env-path", "history-path", "loginshell-path"];
28+
let mut cols = vec![
29+
"default-config-dir",
30+
"config-path",
31+
"env-path",
32+
"history-path",
33+
"loginshell-path",
34+
];
2935

3036
#[cfg(feature = "plugin")]
3137
if self.engine_state.plugin_signatures.is_some() {
@@ -70,6 +76,17 @@ impl LazyRecord for NuVariable {
7076
}
7177

7278
match column {
79+
"default-config-dir" => {
80+
if let Some(mut path) = nu_path::config_dir() {
81+
path.push("nushell");
82+
Ok(Value::String {
83+
val: path.to_string_lossy().to_string(),
84+
span: self.span,
85+
})
86+
} else {
87+
err("Could not get config directory")
88+
}
89+
}
7390
"config-path" => {
7491
if let Some(path) = self.engine_state.get_config_path("config-path") {
7592
let canon_config_path = canonicalize_path(&self.engine_state, path);

crates/nu-utils/src/sample_config/default_env.nu

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,14 @@ let-env ENV_CONVERSIONS = {
7272
#
7373
# By default, <nushell-config-dir>/scripts is added
7474
let-env NU_LIB_DIRS = [
75-
($nu.config-path | path dirname | path join 'scripts')
75+
($nu.default-config-dir | path join 'scripts')
7676
]
7777

7878
# Directories to search for plugin binaries when calling register
7979
#
8080
# By default, <nushell-config-dir>/plugins is added
8181
let-env NU_PLUGIN_DIRS = [
82-
($nu.config-path | path dirname | path join 'plugins')
82+
($nu.default-config-dir | path join 'plugins')
8383
]
8484

8585
# To add entries to PATH (on Windows you might use Path), you can use the following pattern:

0 commit comments

Comments
 (0)