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

fix: Fix syntax error on activate nu when PATH contains shims #4349

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

atty303
Copy link

@atty303 atty303 commented Feb 9, 2025

Background and Purpose

When nushell has shims in the PATH, activate nu outputs an incorrect script.

The problem is at the beginning of the script generated by activate nu

set,Path,C:\Program Files\Microsoft VS Code\bin;C:\Program Files\PowerShell\7

This gives the following error in nushell 0.102.

Error: nu::shell::external_command

  × External command failed
   ╭─[entry #55:1:1]
 1 │ set,Path,C:\Program Files\Microsoft VS Code\bin;C:\Program Files\PowerShell\7
   · ─────────┬─────────
   ·          ╰── Command `set,Path,C:\Program` not found
   ╰────
  help: `set,Path,C:\Program` is neither a Nushell built-in or a known external command

This is not a Nu script, but a CSV protocol.
The nushell functions defined in activate (def “parse vars”) parse CSV only for deactivate, shell and sh command output.
The CSV protocol is not available in activate itself, so it must output valid Nu scripts.

Changes

  • Shell::set_env should change the output if it is running in the context of activate. I introduced enum ActivatePrelude to avoid making it mutable.

Impact

  • The output of other shells is kept the same.

Introduce `ActivatePrelude` to streamline environment updates during shell activation. This change consolidates logic for setting and prepending environment variables, reducing duplication across shells. Adjusted shell-specific activation code to utilize the new abstraction for cleaner implementation.
@atty303 atty303 changed the title fix: Fix syntax error on nushell when PATH contains spaces fix: Fix syntax error on activate nu when PATH contains shims Feb 9, 2025
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.

1 participant