Files
Darren Schroeder bf111f1aca Drop 18 crates from Cargo.lock and stop building nu-protocol twice (#19665)
## Description

I'm not sure how helpful this will be since we change things all the
time but it's probably a good practice to look around and see how we can
reduce the amount of crates we use.

This PR removes dependencies nushell can do without. Rewriting `random
pass` without aegis turned up three bugs in it, and moving `get_umask`
turned up a race in `umask`. The PR fixes those too.

- `nu-cmd-extra`'s build script included `theme.rs`, which derives
`nu_protocol::IntoValue`. To read one JSON file, cargo built a second
copy of nu-protocol and everything under it. The build script now has
its own serde struct, and the generated theme list is byte-identical.
- `nu-system` depended on uucore (with clap, fluent and ICU) only for
`get_umask`, and only nu-command calls it. nu-command now has that
function, so every plugin drops 44 crates. `nu_system::get_umask` stays
as a deprecated function that reads the umask through nix.
- `random pass` uses `rand` 0.10 directly instead of
`aegis-password-generator`, which pulled in rand 0.9 and thiserror 1.
- `random uuid -v 3` hashes with the `md-5` 0.11 crate that `hash md5`
already uses, instead of uuid's `v3` feature and its older RustCrypto
stack.
- Hand-written setters with the same signatures replace `derive_setters`
and darling 0.21. `ParseOptions::with_keep_styles` is now deprecated,
like the `keep_styles` field it sets.
- `UniqueString` wraps a `Box<str>` instead of byteyarn's `Yarn`, which
brought zerocopy 0.7.
- parking_lot, lru and nix go back one minor version to match crossterm,
ratatui and uucore, so each one is built once.
- Lockfile bumps of instability and kasuari let ratatui share darling
0.24 and hashbrown 0.17. serde-saphyr stays at 2.1.1 but now resolves
base64 0.23, which its `>=0.21, <0.24` range already allows.
- 31 unused entries are gone from crate manifests, along with the
`dirs-sys` and `webpki-roots` workspace entries that nothing uses.

The `random pass` fixes:

- `--chars` below 4 returned 4 characters, because the password always
took one character from each enabled set. It now returns the requested
length. `--require-each-type` with fewer than 4 characters is an error.
- `--include-ambiguous` and `--include-similar` did nothing, because
aegis ignored them. Passwords now leave out `O 0 l 1 i` by default, as
the help text says, and each flag adds its characters back.
- A negative `--chars` failed with "must be less than or equal to 128".
It now says "greater than 0", and length errors point at the `--chars`
value.

The `umask` fix: reading the umask sets it to 0 for a moment. `umask
<mask>` didn't take the lock that reads take, so a set that landed in
that moment reported `rwxrwxrwx` as the previous mask, and the read then
undid it. Reads and sets now share one lock.

| macOS, default features | main | this PR |
|---|---|---|
| crates in the `nu` build | 582 | 554 |
| crates in a plugin build (`nu_plugin_inc`) | 209 | 150 |
| crates in `nu_plugin_polars` | 481 | 448 |
| packages in `Cargo.lock` | 1029 | 1011 |
| compile units, `cargo build` | 648 | 572 |
| compile units, `cargo build --release` | 740 | 587 |


## User-facing changes (Release notes)

- `random pass --chars` returns exactly the requested length. Below 4 it
used to return 4 characters.
- `random pass` leaves out the look-alike characters `O 0 l 1 i` unless
`--include-ambiguous` or `--include-similar` is given, as its help says.
- `umask <mask>` no longer reports `rwxrwxrwx` as the previous mask, or
loses the new one, when another thread reads the umask at the same time.
- Plugins built on `nu-plugin` compile 59 fewer crates (209 to 150 for
`nu_plugin_inc` on macOS).


## Additional notes
<!--
Optional.

Examples:
- fixes #123
- closes #456
- related #789

Anything else reviewers should know.
Remove this section if not needed.
-->
2026-11-25 13:11:24 -06:00
..
2023-04-07 13:39:21 -07:00

Welcome to the standard library of `nushell`!

The standard library is a pure-nushell collection of custom commands which provide interactive utilities and building blocks for users writing casual scripts or complex applications.

To see what's here:

> use std
> scope commands | select name description | where name =~ "std "
#┬───────────name────────────┬───────────────────description───────────────────
0│std assert                 │Universal assert command
1│std assert equal           │Assert $left == $right
2│std assert error           │Assert that executing the code generates an error
3│std assert greater         │Assert $left > $right
4│std assert greater or equal│Assert $left >= $right
             ...                                     ...
─┴───────────────────────────┴─────────────────────────────────────────────────

🧰 Using the standard library in the REPL or in scripts

All commands in the standard library must be "imported" into the running environment (the interactive read-execute-print-loop (REPL) or a .nu script) using the use command.

You can choose to import the whole module, but then must refer to individual commands with a std prefix, e.g:

use std

std log debug "Running now"
std assert (1 == 2)

Or you can enumerate the specific commands you want to import and invoke them without the std prefix.

use std ["log debug" assert]

log debug "Running again"
assert (2 == 1)

This is probably the form of import you'll want to add to your env.nu for interactive use.

✏️ contribute to the standard library

You're invited to contribute to the standard library! See CONTRIBUTING.md for details