Repository navigation
Description
Describe the bug
-
When starting with
nu --no-config-file/-n:- the Nushell defaults for
$env.configare not populated into the environment. The defaults are still in play if they haven't been overwritten by a corresponding variable in the environment, but they cannot be introspected by the user with, e.g.,$env.config.color_config. $env.NU_LIB_DIRSis populated with a default, even if it was not present in the parent process$env.PROMPT_variables are not populated by default, but may be inherited from the parent process.
- the Nushell defaults for
-
When starting with an empty or user-generated
config.nuorenv.nuthe default config values are also not populated into the environment. Same rules as above apply. -
However, when starting
nuwhen noenv.nuand/orconfig.nuexists, Nushell will ask the user if they want to create one. If the user responds with "n"/No, then there is no file, but$env.configis fully populated with the defaults (when there is noconfig.nu), as are$env.PROMPT_*variables when there is noenv.nu.
How to reproduce
Best to run all of these from a parent Bash process where there are no Nushell environment variables set. For Windows users, WSL makes this pretty easy by starting with wsl ~ -e /usr/bin/bash.
-
Scenario 1 above
nu -n $env.config # => Result $env.config 08/22/2024 09:34:23 AM Error: nu::shell::column_not_found × Cannot find column 'config' ╭─[entry #1:1:1] 1 │ $env.config · ──┬─ ───┬── · │ ╰── cannot find column 'config' · ╰── value originates here ╰──── $env.NU_LIB_DIRS # => Result ╭───┬────────────────────────────────────────────╮ │ 0 │ /home/ntd/.config/nushell/scripts │ │ 1 │ /home/ntd/.local/share/nushell/completions │ ╰───┴────────────────────────────────────────────╯
-
Scenario 2 above:
Important: Run through Scenario 3 to start, but don't exit Nushell when finished.
touch ($nu.default-config-dir | path join "config.nu") # Exit Nushell, don't exit Bash so that the XDG_CONFIG_HOME is still in play nu # Get prompt only for env.nu - Say "no" $env.config.color_config.block # => Result Error: nu::shell::column_not_found × Cannot find column 'config' ╭─[entry #1:1:1] 1 │ $env.config.color_config.block · ──┬─ ───┬── · │ ╰── cannot find column 'config' · ╰── value originates here ╰──── # default_env.nu is still in play view source ($env.PROMPT_COMMAND) # => {|| create_left_prompt }
-
Scenario 3 above:
# from bash export XDG_CONFIG_HOME=$(mktemp -d) nu # Say n to both prompts $env.config.color_config.block # => white view source ($env.PROMPT_COMMAND) # => {|| create_left_prompt } view source create_left_prompt # => Prompt function is defined view files | find default # => ╭───┬───────────────────┬───────┬────────┬───────╮ │ # │ filename │ start │ end │ size │ ├───┼───────────────────┼───────┼────────┼───────┤ │ 0 │ default_env.nu │ 85633 │ 89910 │ 4277 │ │ 1 │ default_config.nu │ 89967 │ 119773 │ 29806 │ ╰───┴───────────────────┴───────┴────────┴───────╯
Expected behavior
My ideal scenario is more of an enhancement request that I'll open separately, but I would expect more consistency in the way that default_config.nu and default_env.nu are loaded.
Screenshots
No response
Configuration
| key | value |
|---|---|
| version | 0.97.1 |
| major | 0 |
| minor | 97 |
| patch | 1 |
| branch | |
| commit_hash | |
| build_os | linux-x86_64 |
| build_target | x86_64-unknown-linux-gnu |
| rust_version | rustc 1.80.1 (3f5fd8dd4 2024-08-06) |
| rust_channel | stable-x86_64-unknown-linux-gnu |
| cargo_version | cargo 1.80.1 (376290515 2024-07-16) |
| build_time | 2024-08-21 13:13:11 -04:00 |
| build_rust_channel | release |
| allocator | mimalloc |
| features | default, sqlite, system-clipboard, trash |
| installed_plugins | formats 0.96.1, inc 0.96.1 |
Additional context
No response
Activity
fdncred commentedon Aug 22, 2024
As discussed on discord and other places, it's probably important to understand what we want loaded when each parameter is passed into nushell.
I created this gist to demonstrate how nushell is currently processing config files. There definitely are edge cases that may change these results as listed above.
Just thinking outloud, maybe it would be good to list all parameters in one column, description in another, and what we want loaded in other columns.
Moves additional env vars out of default_env and updates some transie…