-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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: use recommended way of updating Fish shell $PATH #11349
Conversation
@@ -78,7 +78,7 @@ def prepend_path_in_profile(path) | |||
when :csh, :tcsh | |||
"echo 'setenv PATH #{csh_quote(path)}:$PATH' >> #{profile}" | |||
when :fish | |||
"echo 'set -g fish_user_paths \"#{sh_quote(path)}\" $fish_user_paths' >> #{profile}" | |||
"echo 'fish_add_path #{sh_quote(path)}' >> #{profile}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function was only added in fish 3.2.0 [1] (also see #8965 (comment)). Is there a utility function we can use to get the version of the shell? I don't see anything for version here [2].
1: https://github.com/fish-shell/fish-shell/releases/tag/3.2.1
2: https://github.com/Homebrew/brew/blob/master/Library/Homebrew/utils/shell.rb#
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @MikeMcQuaid if you have any idea 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Various shells have env vars that indicate their version [3]. Would it be worth adding (in another PR) a method in utils/shell.rb
[4] called preferred_version
that tries to return the user's preferred shell's version and nil if it can't be determined?
3: https://stackoverflow.com/a/38240328/553994
4: https://github.com/Homebrew/brew/blob/master/Library/Homebrew/utils/shell.rb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if it works in the latest stable brew install fish
that's sufficient.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Latest stable fish version in brew is 3.2.2 so we should be good. https://github.com/Homebrew/homebrew-core/blob/a84689c7557c96dcf648fed27031cae6d2d3aa8f/Formula/fish.rb#L4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Marked PR as ready for review. PTAL thanks!
fixes Homebrew#8965 See Fish docs https://fishshell.com/docs/current/tutorial.html#path. > A faster way is to use the `fish_add_path function`... The advantage is that > you don't have to go mucking around in files: just run this once at the > command line, and it will affect the current session and all future instances > too. > > Or you can modify `$fish_user_paths` yourself, but you should be careful not > to append to it unconditionally in config.fish, or it will grow longer and > longer.
Thanks again @davidxia! |
fixes #8965
See Fish docs https://fishshell.com/docs/current/tutorial.html#path.
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?