Why does brew shellenv
put linuxbrew in $PATH
before /usr/bin/ ?
#2560
-
The recommendation is to put:
in one of my dotfiles. When I run Why put Running on Ubuntu 20.04 LTS under WSL2. DetailsWhen I run
So
(Yes, I could've installed
As far as I can see, everything works if I swap the order in the |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 10 replies
-
Because brew does not expect you to use a second package manager at the same time (and neither does apt). As for the second part of this, there is no guaranteeing that brew apps work either way. We try our best to make packages work with our dependencies but we don't develop them so we can't be sure it'll work. |
Beta Was this translation helpful? Give feedback.
-
You can reverse the order of Homebrew's prefix and |
Beta Was this translation helpful? Give feedback.
-
So I guess I have no choice but to decide whether I prefer The best way I could come up with was this for
Thank you for your replies, @SMillerDev and @carlocab |
Beta Was this translation helpful? Give feedback.
-
FYI, this is still causing breakage in 2024. This reply by @pmorch seems to still resolve it as a workaround. |
Beta Was this translation helpful? Give feedback.
-
I just implemented it like this for myself, to avoid duplicates in the path. I added a check if # Load homebrew shellenv
BREW=/home/linuxbrew/.linuxbrew/bin/brew
if [ -x "$BREW" -a -z "$HOMEBREW_PREFIX" ]; then
PREV_PATH=$PATH
# brew needs tools like dirname and readlink
PATH=/usr/bin
# this sets PATH, HOMEBREW_PREFIX, HOMEBREW_CELLAR, HOMEBREW_REPOSITORY
eval "$($BREW shellenv)"
export PATH=$PREV_PATH${PATH+:$PATH}
fi |
Beta Was this translation helpful? Give feedback.
Because brew does not expect you to use a second package manager at the same time (and neither does apt). As for the second part of this, there is no guaranteeing that brew apps work either way. We try our best to make packages work with our dependencies but we don't develop them so we can't be sure it'll work.