-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
pyenv not playing nice with brew "config". [$5] #106
Comments
Duplication of #42. This can't be avoidable because |
what about just turning off pyenv (comment out the eval and sourcing the rc file) before installing something with brew? |
@nZac You don't have to modify rc file. Just setting the version as |
@yyuu thanks for the details. |
@yyuu Is setting |
@sayhar |
@blueyed You understand correctly. For the user of pyenv who don't want complicated thing about |
This fact sound be displayed much more prominently. Is there a way to build a config that would take care of this for you? If
|
I don't have any general solution to solve this issue, because this warning is thrown outside from |
http://www.task-notes.com/entry/20141223/1419324649 |
@Szkered, thanks for the link. I am using the following slightly more generic alias.
|
+1 for the alias brew approach above. This fixed the issue for me for now. |
👍 for @randy3k . Maybe we can add it as a hint in the caveats section when installing with brew? Too soon; the alias breaks completions. Any ideas how to fix the zsh-completions? |
@wadkar For the same reason...I stopped using it. I now just ignore the warnings... |
Hmm, so if I keep the |
@randy3k |
Just use a wrapper script instead of an alias, place it in a prefixed entry in PATH. Completion works great that way. The reason completions don't work is zsh does not complete aliases without the completealias option, and it's off by default for a reason --- it's rather common to break things by design with one. |
TL;DR : Create a script with code in the second block below and name it as Thanks! # set path to include personal bin in your .zshrc or .bashrc or whatever
export PATH="${HOME}/bin:${PATH}" and put following in an executable script in #!/bin/sh
# check if pyenv is available
# edit: fixed redirect issue in earlier version
if which pyenv > /dev/null 2>&1; then
# assumes default location of brew in `/usr/local/bin/brew`
/usr/bin/env PATH="${PATH//$(pyenv root)\/shims:/}" /usr/local/bin/brew "$@"
else
/usr/local/bin/brew "$@"
fi Would it be possible to link this issue/comment to wiki/docs? If you're using |
@wadkar do you call this script "brew" or something else? |
Yes, just call it brew. The point is to "wrap" the execution of the original. |
My comment mentions the name of the file as |
While using tmux each new shell in tmux will create a login shell. This creates duplicate entries in Here's my current solution for the duplicate entries in # cat ~/.zprofile
# fix duplicate entries in PATH when using tmux
# see: https://github.com/rbenv/rbenv/issues/369#issuecomment-36010083
if [ -n "${TMUX}" -a -f /etc/profile ]; then
PATH=''
source /etc/profile
fi |
Since you're on ZSH, you have the benefit of making an array act as an $path is PATH in array form, -U discards non-unique entriestypeset -U path Happy hacking! |
If pyenv had a way to use as pointed out in Linuxbrew/legacy-linuxbrew#764 (comment) this is recommended in PEP 0394 as well |
@wadkar should be "2>&1"? #!/bin/sh
if which pyenv > /dev/null 2>&1; then
# assumes default location of brew in `/usr/local/bin/brew`
/usr/bin/env PATH="${PATH//$(pyenv root)\/shims:/}" /usr/local/bin/brew "$@"
else
/usr/local/bin/brew "$@"
fi |
You are correct. I have edited my response. |
for even more clarification, is it recommended to use system version of Python before installing something via brew? in other words, is the current recommendation to use system python and this alias in order to really "fix" everything? or, if we don't want to remember to use system Python when installing something new via brew then should we instead use the executable shell script wrapper identified earlier? or, perhaps setting I'm trying to figure this out, learn it from scratch ;-), and make sure I don't skip something important. I've implemented the alias which definitely helped the |
I think when you install something via brew that has python dependencies, then that package will have dependency on brewed python. For example, So to answer your question in short, no, I wouldn't link brew installed packages against system python. Therefore, the alias/script removes pyenv from the path before calling brew. |
Thanks, @wadkar - this alias did the trick for me. I was a bit concerned about aliasing Update: Well, shit. Now, when I use Filed as Issue #1156 with thefuck. Update #2: Nevermind, carry on, this one was my fault. |
Here's the fish version: # Make pyenv play nice with Homebrew
# https://github.com/pyenv/pyenv/issues/106
alias brew="env PATH=(string replace (pyenv root)/shims '' (echo $PATH)) brew" |
Correction to the fish version: The previous version expands the current PATH before creating the alias, so if you make any future changes to your path they won't be reflected in the alias. You want the actual alias definition to be: So you need a bunch of escapes for the quote and '$' around the PATH reference in the command defining the alias. |
I've added the lines proposed above into the README noting when exactly they are needed. See https://github.com/pyenv/pyenv#homebrew-in-macos |
|
@jprokos http://idownvotedbecau.se/itsnotworking/ . |
Would it matter if the shell was zsh? I see some earlier comments regarding how zsh interprets aliases. |
The command is for Zsh (since it's only applicable for MacOS), I've tested it and it WFM:
|
Prior to this `brew doctor` throws warnings about conflicting configs. This change, taken from pyenv/pyenv#106 (comment) fixes this conflict by removing pyenv from the path while running brew commands.
Ok I have a new update on the fish shell one... Two versions:
alias brew 'PATH=(string replace (pyenv root)/shims: "" "$PATH") command brew'
function brew
set -xf PATH $PATH
if set i (contains -i (pyenv root)/shims $PATH)
set -e PATH[$i]
end
command brew $argv
end |
Is this issue fixed?
Im not sure if this is pyenv problem
|
Does anyone have a zsh equivalent to the fish function above? Seems like the best way to handle this. Cheers! |
@native-api - damn you are fast! Thanks so much! |
I installed python 2.7.6 and python 3.3.3 with pyenv.
Now when I run
brew doctor
I get the following warning:How can this be fixed so it plays nice with brew?
--- There is a **[$5 open bounty](https://www.bountysource.com/issues/2813423-pyenv-not-playing-nice-with-brew-config?utm_campaign=plugin&utm_content=tracker%2F282009&utm_medium=issues&utm_source=github)** on this issue. Add to the bounty at [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F282009&utm_medium=issues&utm_source=github).C.
The text was updated successfully, but these errors were encountered: