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

fish_add_path creates empty PATH #8082

Closed
acook opened this issue Jun 23, 2021 · 2 comments
Closed

fish_add_path creates empty PATH #8082

acook opened this issue Jun 23, 2021 · 2 comments

Comments

@acook
Copy link

acook commented Jun 23, 2021

fish, version 3.2.2

MacOS 11.4
Darwin Kernel Version 20.5.0: Sat May 8 05:10:33 PDT 2021; root:xnu-7195.121.3~9/RELEASE_X86_64 x86_64
iTerm 3.4.8
xterm-256color

I've seen 2 behaviors.

One is easy to replicate - if PATH is empty before fish_add_path, then it will remain empty:

> set -e PATH
> fish_add_path -Pv "/usr/local/bin"
set PATH /usr/local/bin
> echo $PATH

> set PATH /bin
> fish_add_path -Pv "/usr/local/bin"
set PATH /usr/local/bin /bin
> echo $PATH
/usr/local/bin /bin

The second behavior I'm beginning to think was a false memory. But I swear in some situations I've seen it keep only the path passed in, and ignore all the others. This might have been because I believed -v was actually doing something when it wasn't.

@faho
Copy link
Member

faho commented Jun 23, 2021

One is easy to replicate - if PATH is empty before fish_add_path, then it will remain empty:

Not empty, undefined.

You've entirely erased $PATH, so when fish_add_path does set PATH, that sets it in the default scope, which is local. We should make it default to global here.

However: You shouldn't erase $PATH. $PATH should typically be set by the system - because that knows where stuff is! Ff that doesn't work fish even tries to give you a fallback so you don't end up with a broken configuration.

If you want to completely reset $PATH to a specific value, just skip fish_add_path and all that and set it directly - set -g PATH /usr/bin or whatever.

@faho faho closed this as completed in cc54917 Jun 23, 2021
@faho faho added this to the fish 3.3.0 milestone Jun 23, 2021
@acook
Copy link
Author

acook commented Jun 23, 2021

Ah, that makes sense re "undefined" and "scope". Thanks for the quick fix!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants