Skip to content

Commit 22358f7

Browse files
james-smith-zaJames Smithysthakur
authored
Document deprecation of $env.NU_LIB_DIRS (#2101)
* Document deprecation of $env.NU_LIB_DIRS 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. * Apply suggestions from code review --------- Co-authored-by: James Smith <james@cloudstroller.xyz> Co-authored-by: Yash Thakur <45539777+ysthakur@users.noreply.github.com>
1 parent c53bbe6 commit 22358f7

4 files changed

Lines changed: 13 additions & 7 deletions

File tree

book/configuration.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,12 +390,12 @@ The variables that affect Nushell file locations are:
390390

391391
Once Nushell starts, this value is stored in the `$nu.default-config-dir` constant. See [Using Constants](#using-constants) below.
392392

393-
- `$env.XDG_DATA_HOME`: If this environment variable is set, Nushell sets the `$nu.data-dir` constant to this value. The `data-dir` is used in several startup tasks:
393+
- `$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:
394394

395-
- `($nu.data-dir)/completions` is added to the `$env.NU_LIB_DIRS` search path.
395+
- `($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).)
396396
- `($nu.data-dir)/vendor/autoload` is added as the last path in `nu.vendor-autoload-dirs`. Files in this directory will be read after the other vendor-auto-load directories, thus overriding any of their settings.
397397

398-
Note that the directory represented by `$nu.data-dir`, nor any of its subdirectories, are created by default. Creation and use of these directories is up to the user.
398+
Note that the directory represented by `$nu.data-dir`, including any of its subdirectories, are NOT created by default. Creation and use of these directories is up to the user.
399399

400400
- `$env.XDG_DATA_DIRS` _(Unix Platforms Only)_: If this environment variable is set, it is used to populate the `$nu.vendor-auto-load` directories in the order listed. The first directory in the list is processed first, meaning the last one read will have the ability to override previous definitions.
401401

book/modules/creating_modules.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ Also notice that, because the commands from `increment` and `range-into-list` ar
305305

306306
## Environment Variables
307307

308-
Modules can define an environment using [`export-env`](/commands/docs/export-env.md). Let's extend our `my-utils` module with an environment variable export for a common directory where we'll place our modules in the future. This directory is (by default) in the `$env.NU_LIB_DIRS` search path discussed in [Using Modules - Module Path](./using_modules.md#module-path).
308+
Modules can define an environment using [`export-env`](/commands/docs/export-env.md). Let's extend our `my-utils` module with an environment variable export for a common directory where we'll place our modules in the future. This directory is (by default) in the `$NU_LIB_DIRS` search path discussed in [Using Modules - Module Path](./using_modules.md#module-path).
309309

310310
```nu
311311
# A collection of helpful utility functions

book/modules/using_modules.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ The path to the module can be:
6969
Note that the module name (its directory) can end in a `/` (or `\` on Windows), but as with most commands that take a paths (e.g., `cd`), this is completely optional.
7070
:::
7171

72-
::: important Important! Importing modules from `$env.NU_LIB_DIRS`
73-
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.
72+
::: important Important! Importing modules from `$NU_LIB_DIRS` or `$env.NU_LIB_DIRS`
73+
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).
7474

7575
This allows you to install modules to a location that is easily accessible via a relative path regardless of the current directory.
7676
:::
7777

78-
- An absolute or relative path to a Nushell module file. As above, Nushell will search the `$env.NU_LIB_DIRS` for a matching relative path.
78+
- An absolute or relative path to a Nushell module file. As above, Nushell will search the constant `$NU_LIB_DIRS` and then `$env.NU_LIB_DIRS` for a matching relative path.
7979

8080
::: details Example
8181

book/special_variables.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ try {
101101

102102
### `$env.NU_LIB_DIRS`
103103

104+
::: warning
105+
106+
As of version 0.101.0, this environment variable is marked as deprecated. Users should prefer the `$NU_LIB_DIRS` constant (see below).
107+
108+
:::
109+
104110
A list of directories which will be searched when using the `source`, `use`, or `overlay use` commands. See also:
105111

106112
- The `$NU_LIB_DIRS` constant below

0 commit comments

Comments
 (0)