Skip to content

fix(env): call Nushell built-ins with the % sigil in env.nu - #3123

Open
naokihaba wants to merge 10 commits into
voidzero-dev:mainfrom
naokihaba:fix/nushell-env-builtin-shadowing
Open

naokihaba wants to merge 10 commits into
voidzero-dev:mainfrom
naokihaba:fix/nushell-env-builtin-shadowing

Conversation

@naokihaba

Copy link
Copy Markdown
Collaborator

Context

If a Nushell user defines a custom command with the same name as a built-in command such as update, for example def update [], Nushell does not start. Nushell resolves command names at parse time, and it reads the Vite+ env.nu after the user's configuration. Thus, the update call in env.nu resolves to the user's command. The arguments do not match, and Nushell stops at startup with nu::parser::extra_positional.

To prevent this, env.nu now calls each built-in command with the % sigil, for example %update. With the sigil, Nushell runs the built-in command even if a custom command has the same name.

Nushell 0.112.1 added the % sigil, as the release notes state, and earlier versions cannot parse it. Thus, vp env setup now checks the version of the nu on PATH and adds the sigil only for 0.112.1 or later. For an earlier version, it writes the same env.nu as before this change. Users of an earlier version who shadow these commands still cannot start Nushell until they upgrade Nushell and run vp env setup again. The documentation now describes this procedure.

`vp env setup` will select the `env.nu` syntax from the Nushell version.
VP_NU_VERSION gives that version directly, so `vp env setup` does not run
`nu`. Tests use it to make the generated `env.nu` independent of the
installed Nushell.
Nushell resolves command names at parse time, and it parses the Vite+
env.nu after the user's config. A user command with the name of a
built-in, such as `def update []`, replaced the built-in that env.nu
calls, and Nushell stopped at startup with `nu::parser::extra_positional`.

env.nu now calls each built-in that a user can shadow with the `%` sigil,
and calls `fish` as `^fish`. Nushell 0.112.1 added the sigil, and earlier
versions cannot parse it. Thus, `vp env setup` asks the `nu` on PATH for
its version and writes the sigils only for 0.112.1 or later. In other
cases, it writes the same env.nu as before.

Fixes voidzero-dev#3092
Recommend Nushell 0.112.1 or later, and tell users with an earlier version
to run `vp env setup` again after they upgrade Nushell.
`vp env setup` waited for `nu -c "version | get version"` without a limit.
A `nu` that did not answer stopped `vp env setup`. Stop the check after 5
seconds, kill `nu`, and write the env.nu without the `%` sigil.

Also cite the Nushell 0.112.1 release notes for the version that added
the `%` sigil.
`vp env setup` selects the env.nu syntax from the `nu` on PATH. A Nushell
earlier than 0.112.1 cannot parse an env.nu written for a later version,
so tell users with more than one installation to use the same `nu`.
@naokihaba naokihaba self-assigned this Oct 19, 2026
@naokihaba

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T15:20:05.084613Z 16bf332 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7012acdb3c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/vp_global_cli/src/commands/env/setup.rs
@naokihaba
naokihaba marked this pull request as ready for review October 19, 2026 14:12
@naokihaba
naokihaba requested review from fengmk2 and nekomoyi October 19, 2026 14:12
Comment thread crates/vp_global_cli/src/commands/env/setup.rs Outdated
`nu --version` prints the same bare version as
`nu -c "version | get version"`, but it exits before the engine starts.
Thus, the user's config, autoload files, and plugins cannot affect the
check, and the check is faster.
@naokihaba

Copy link
Copy Markdown
Collaborator Author

@codex review

@naokihaba
naokihaba marked this pull request as draft October 19, 2026 15:13
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 16bf332f2d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@naokihaba
naokihaba marked this pull request as ready for review October 19, 2026 16:21

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nushell env bug: Positional completer input deprecated

3 participants