Skip to content

Conversation

@Jasha10
Copy link
Contributor

@Jasha10 Jasha10 commented Nov 13, 2024

This PR updates the nushell cookbook's direnv integration recommendation so that $env.PATH will be stored as a nushell list rather than as a colon-separated string.

Before this change, my $env.PATH looks like this:

> $env.PATH
/Users/jasha/bin:/Users/jasha/.cargo/bin:/Users/jasha/.local/bin:/Users/jasha/.nvm/versions/node/v18.19.0/bin:/Users/jasha/.pyenv/shims:/opt/homebrew/bin:/opt/homebrew/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Applications/iTerm.app/Contents/Resources/utilities

After the change, `$env.PATH looks like this:

> $env.PATH
╭────┬───────────────────────────────────────────────────────────────────────────────────╮
│  0 │ /Users/jasha/bin                                                                  │
│  1 │ /Users/jasha/.cargo/bin                                                           │
│  2 │ /Users/jasha/.local/bin                                                           │
│  3 │ /Users/jasha/.nvm/versions/node/v18.19.0/bin                                      │
│  4 │ /Users/jasha/.pyenv/shims                                                         │
│  5 │ /opt/homebrew/bin                                                                 │
│  6 │ /opt/homebrew/sbin                                                                │
│  7 │ /bin                                                                              │
│  8 │ /sbin                                                                             │
│  9 │ /usr/bin                                                                          │
│ 10 │ /usr/sbin                                                                         │
│ 11 │ /usr/local/bin                                                                    │
│ 12 │ /System/Cryptexes/App/usr/bin                                                     │
│ 13 │ /var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin         │
│ 14 │ /var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin               │
│ 15 │ /var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin │
│ 16 │ /Applications/iTerm.app/Contents/Resources/utilities                              │
╰────┴───────────────────────────────────────────────────────────────────────────────────╯

I have verified that the direnv integration still works as expected, with $env.PATH being modified when I cd into or out of a direnv-managed directory.

@Jasha10
Copy link
Contributor Author

Jasha10 commented Nov 13, 2024

Question for reviewers: should we add defensive logic for the case where the user has not set up their $env.ENV_CONVERSIONS table?

E.g.

            if 'ENV_CONVERSIONS' in ($env | columns) and 'PATH' in ($env.ENV_CONVERSIONS | columns) {
              $env.PATH = do $env.ENV_CONVERSIONS.PATH.from_string $env.PATH
            }

@fdncred
Copy link
Contributor

fdncred commented Nov 13, 2024

should we add defensive logic ...

yes. with the current release, I think it's possible to not have ENV_CONVERSIONS at all. the next release may change that though.

@Jasha10
Copy link
Contributor Author

Jasha10 commented Nov 13, 2024

@fdncred updated in commit f0edb31

Co-authored-by: Darren Schroeder <[email protected]>
@fdncred fdncred merged commit fb3c7a2 into nushell:main Nov 16, 2024
2 checks passed
@fdncred
Copy link
Contributor

fdncred commented Nov 16, 2024

Thanks

@Jasha10 Jasha10 deleted the patch-1 branch November 16, 2024 15:40
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.

2 participants