Skip to content

Commit

Permalink
Be more specific about std/log use in modules (#1630)
Browse files Browse the repository at this point in the history
  • Loading branch information
NotTheDr01ds authored Nov 14, 2024
1 parent 406ffa6 commit 37c713b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions book/modules/creating_modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,10 @@ Running this command changes the directory _locally_ in the module, but the chan

### `export-env` runs only when the `use` call is _evaluated_

::: note
This scenario is commonly encountered when creating a module that uses `std/log`.
:::

Attempting to import a module's environment within another environment may not work as expected. Let's create a new module `go.nu` that creates "shortcuts" to common directories. One of these will be the `$env.NU_MODULES_DIR` defined above in `my-utils`.

We might try:
Expand Down
7 changes: 7 additions & 0 deletions book/standard_library.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@ nu -n -c "$nu.startup-time"

You will not be able to import the library, any of its submodules, nor use any of its commands, when it is disabled in this way.

## Using `std/log` in Modules

::: warning Important!
`std/log` exports environment variables. To use the `std/log` module in your own module, please see [this caveat](./modules/creating_modules.md#export-env-runs-only-when-the-use-call-is-evaluated) in the "Creating Modules" Chapter.

:::

## Optimal Startup

If Nushell's startup time is important to your workflow, review your [startup configuration]([./configuration.md]) in `config.nu`, `env.nu`, and potentially others for inefficient use of the standard library. The following command should identify any problem areas:
Expand Down

0 comments on commit 37c713b

Please sign in to comment.