Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Be more specific about std/log use in modules #1630

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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