Skip to content

Conversation

@james-smith-za
Copy link

@james-smith-za james-smith-za commented Jan 2, 2026

Sorry I took a bit longer to draft these changes, I'm going to blame the holiday spirit for my laziness :)

See #2096 for some context.

I went through the docs to see where else the variables in question were mentioned and I updated them. I'm not competent to maintain the other translations, I'm afraid.

I'm also not sure if I got the hyperlinks and the formatting right - those in the know will have to guide me. I tried cargo-culting from other examples.

The $env.NU_LIB_DIRS has been marked deprecated in the nushell source
code for a while now, by default it is an empty list to maintain
compatibility. Users should prefer the constant $NU_LIB_DIRS instead,
which is populated with some things based on environment variables at
nushell startup.

The docs had drifted a bit. This commit serves to update them.
@james-smith-za
Copy link
Author

@ysthakur are you able to take a look?

@ysthakur
Copy link
Member

ysthakur commented Jan 8, 2026

Sorry, slipped my mind. Yes, I'll take a look today or tomorrow

Copy link
Member

@ysthakur ysthakur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good, thanks for improving our docs. Just some minor comments


### `$env.NU_LIB_DIRS`

::: note
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think ::: warning works better here

- `$env.XDG_DATA_HOME`: If this environment variable is set, Nushell sets the `$nu.data-dir` constant to `($env.XDG_DATA_HOME)/nushell`. The `data-dir` is used in several startup tasks:

- `($nu.data-dir)/completions` is added to the `$env.NU_LIB_DIRS` search path.
- `($nu.data-dir)/completions` is added to the `const` variable `$NU_LIB_DIRS` search path. (Note: `$env.NU_LIB_DIRS` is not populated by default and is currently deprecated. See [Special Variables - `$env.NU_LIB_DIRS`](./special_variables.md#env-NU_LIB_DIRS).)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure the entire note is necessary, but it can't hurt. A link to the $NU_LIB_DIRS docs would be helpful though

Suggested change
- `($nu.data-dir)/completions` is added to the `const` variable `$NU_LIB_DIRS` search path. (Note: `$env.NU_LIB_DIRS` is not populated by default and is currently deprecated. See [Special Variables - `$env.NU_LIB_DIRS`](./special_variables.md#env-NU_LIB_DIRS).)
- `($nu.data-dir)/completions` is added to the `const` variable [`$NU_LIB_DIRS`](./special_variables.md#NU_LIB_DIRS). (Note: `$env.NU_LIB_DIRS` is not populated by default and is currently deprecated. See [Special Variables - `$env.NU_LIB_DIRS`](./special_variables.md#env-NU_LIB_DIRS).)

::: important Important! Importing modules from `$env.NU_LIB_DIRS`
When importing a module via a relative path, Nushell first searches from the current directory. If a matching module is not found at that location, Nushell then searches each directory in the `$env.NU_LIB_DIRS` list.
::: important Important! Importing modules from `$NU_LIB_DIRS` or `$env.NU_LIB_DIRS`
When importing a module via a relative path, Nushell first searches from the current directory. If a matching module is not found at that location, Nushell then searches each directory in the constant `$NU_LIB_DIRS` list, and then `$env.NU_LIB_DIRS`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not super important, but if possible, it'd be good to put a "(deprecated)" when the env var is mentioned.

Suggested change
When importing a module via a relative path, Nushell first searches from the current directory. If a matching module is not found at that location, Nushell then searches each directory in the constant `$NU_LIB_DIRS` list, and then `$env.NU_LIB_DIRS`.
When importing a module via a relative path, Nushell first searches from the current directory. If a matching module is not found at that location, Nushell then searches each directory in the constant `$NU_LIB_DIRS` list, and then `$env.NU_LIB_DIRS` (deprecated).

If you choose to do this, the Plugins overview also has a mention of $env.NU_LIB_DIRS

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants