Skip to content

Commit 37c713b

Browse files
authored
Be more specific about std/log use in modules (#1630)
1 parent 406ffa6 commit 37c713b

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

book/modules/creating_modules.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,10 @@ Running this command changes the directory _locally_ in the module, but the chan
346346

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

349+
::: note
350+
This scenario is commonly encountered when creating a module that uses `std/log`.
351+
:::
352+
349353
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`.
350354

351355
We might try:

book/standard_library.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,13 @@ nu -n -c "$nu.startup-time"
146146

147147
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.
148148

149+
## Using `std/log` in Modules
150+
151+
::: warning Important!
152+
`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.
153+
154+
:::
155+
149156
## Optimal Startup
150157

151158
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:

0 commit comments

Comments
 (0)