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: use recommended way of updating Fish shell $PATH #11349

Merged
merged 1 commit into from
May 11, 2021

Conversation

davidxia
Copy link
Contributor

@davidxia davidxia commented May 8, 2021

fixes #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.

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

@@ -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}"
Copy link
Contributor Author

@davidxia davidxia May 8, 2021

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#

Copy link
Contributor Author

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 🙏

Copy link
Contributor Author

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

Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

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.
@davidxia davidxia marked this pull request as ready for review May 10, 2021 16:08
@MikeMcQuaid
Copy link
Member

Thanks again @davidxia!

@MikeMcQuaid MikeMcQuaid merged commit f35bb42 into Homebrew:master May 11, 2021
@davidxia davidxia deleted the fish-path branch May 14, 2021 18:59
@github-actions github-actions bot added the outdated PR was locked due to age label Jun 14, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

brew doctor gives incorrect instructions to fix path for fish shell
2 participants