Skip to content

Instantly share code, notes, and snippets.

@fdncred
Last active May 15, 2024 14:18
Show Gist options
  • Save fdncred/b87b784f04984dc31a150baed9ad2447 to your computer and use it in GitHub Desktop.
Save fdncred/b87b784f04984dc31a150baed9ad2447 to your computer and use it in GitHub Desktop.
nushell config file loading

Config file loading rules

  1. default_config.nu and default_env.nu refer to the files that are compiled inside of the nushell executable and are also located in our repo.
  2. personal env.nu/config.nu/login.nu refer to the files that are in the $nu.default-config-dir that you have personally edited.
  3. specified config.nu/env.nu refer to files that are specified on the command line with the --config and --env-config command line parameters.

nu -c "ls"

  • ✅ Always read personal plugin.msgpackz file if it exists
  • ✅ Always reads the default_env.nu file
  • ❌ Does not read default_config.nu file
  • ❌ Does not read personal env.nu file
  • ❌ Does not read personal config.nu file
  • ❌ Does not read personal login.nu file

nu -l -c "ls"

  • ✅ Always reads personal plugin.msgpackz file if it exists
  • ✅ Always reads personal env.nu file if it exists
  • ✅ Always reads personal config.nu file if it exists
  • ✅ Always reads personal login.nu file if it exists
  • ❌ Does not read default_env.nu file
  • ❌ Does not read default_config.nu file

nu -l -c "ls" --config foo_config.nu

  • ✅ Always reads personal plugin.msgpackz file if it exists
  • ✅ Always reads personal env.nu file if it exists
  • ✅ Always reads specified config file if it exists
  • ✅ Always reads personal login.nu file if it exists
  • ❌ Does not read default_env.nu file
  • ❌ Does not read default_config.nu file

nu -l -c "ls" --config foo_config.nu --env-config foo_env.nu

  • ✅ Always reads personal plugin.msgpackz file if it exists
  • ✅ Always reads specified env.nu file if it exists
  • ✅ Always reads specified config.nu file if it exists
  • ✅ Always reads personal login.nu file if it exists
  • ❌ Does not read default_env.nu file
  • ❌ Does not read default_config.nu file

nu -n -l -c "ls"

  • ❌ Does not load personal plugin.msgpackz file
  • ❌ Does not load personal env.nu file
  • ❌ Does not load personal config.nu file
  • ❌ Does not load personal login.nu file
  • ✅ Always reads default_env.nu file (need to confirm)
  • ✅ Always reads default_config.nu file (need to confirm)

nu test.nu

  • ✅ Always reads personal plugin.msgpackz file if it exists
  • ❌ Does not load personal env.nu file
  • ❌ Does not load personal config.nu file
  • ❌ Does not load personal login.nu file
  • ✅ Always reads default_env.nu file (need to confirm)
  • ❌ Does not read default_config.nu file

nu --config foo_config.nu --env-config foo_env.nu test.nu

  • ✅ Always reads personal plugin.msgpackz file if it exists
  • ✅ Always reads specified env.nu file if it exists
  • ✅ Always reads specified config.nu file if it exists
  • ❌ Does not load personal login.nu file
  • ❌ Does not read default_env.nu file
  • ❌ Does not read default_config.nu file

I just updated this 2024-05-15 nushell version 0.93.1

@azarmadr
Copy link

what about the behavior when used in scripts?

@fdncred
Copy link
Author

fdncred commented May 15, 2024

Updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment