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
rbenv rehash on El Capitan does not working #781
Comments
Ouch! Are there any executables when you list |
Seemingly related: my 'rbenv version' output is currently as expected: 2.2.1. But my 'ruby --version' output is 2.0.0p645, which appears to be El Capitan system ruby. |
Same here. After installing rbenv and ruby-build through GitHub checkout, |
For me, the problem was related to PATH variables getting screwed up after Apple moved /etc/zshenv path-setting info to /etc/zprofile. After moving /etc/zprofile back to where it was under Yosemite, i.e., /etc/zshenv, everything went back to normal. |
Add |
@MatthewMDavis I really don't condone any of these suggested zsh fixes. I would leave /etc/zprofile untouched on El Capitan, and instead configure rbenv in ~/.zshrc. |
@mislav, I've seen your spirited advocacy elsewhere on this topic, and you On Thu, Oct 8, 2015 at 4:52 PM, Mislav Marohnić notifications@github.com
|
@MatthewMDavis Sure. I'm glad you solved it, I just wanted to point out to others that sudo moving a system |
Maybe this is something related to the init script? When I run it, I see the following:
|
@metaskills Which |
Well, before posting I had pulled the latest from master, I am also using ZSH too. I did some reading on the thoughtbot link @MatthewMDavis posted and hacked my fix by commenting out the path_helper line in eval `/usr/libexec/path_helper -s`
eval "$(rbenv init -)" I feel this was the least best temporary hack till I get my bearings around the issue more and learn a better way. Before and after, my output of $ rbenv init -
export PATH="/Users/kencollins/.rbenv/shims:${PATH}"
export RBENV_SHELL=zsh
source '/Users/kencollins/.rbenv/libexec/../completions/rbenv.zsh'
rbenv rehash 2>/dev/null
rbenv() {
local command
command="$1"
if [ "$#" -gt 0 ]; then
shift
fi
case "$command" in
rehash|shell)
eval "`rbenv "sh-$command" "$@"`";;
*)
command rbenv "$command" "$@";;
esac
} Thanks so much for posting back @mislav, huge fan and thanks for the work! |
I also want to point out that my issue was not with |
Thoughbot people are also wrong about this thoughtbot/dotfiles#426 It's not that complicated. Please follow these steps and see if it fixes things:
|
Confirmed, that was the best fix! Had to do some cleanup on my side including where I was not adding |
@mislav, simply moving the rbenv init to .zshrc is working, which is great. a. it didn't work way back when, and I assume that a. is now fixed because path_helper is working in a sane On Sun, Oct 11, 2015 at 5:48 AM, Ken Collins notifications@github.com
|
I remember that too, it was one reason I had all the path stuff as part of the env. |
zsh documentation itself fails to leave strong advice about this and the community is generally undecided. But it all makes sense if you look at the list of configuration files that zsh loads in interactive + login mode (default mode for shells in Terminal on OS X):
But basically for your login shell you could just as well do all your configuration in |
@mislav Do you think moving to zshrc vs zshenv for path stuff will impact Pow? I can't seem to get rbenv to work now with it. |
It might; I don't use Pow so I didn't notice. Pow does a hack where it executes your login shell to look for your environment variables. This is rougly what it does: login -qf $LOGNAME "$(dscl . -read /Users/$LOGNAME UserShell | awk '{print $2}')" \
-i -c 'env' | grep ^PATH Can you execute that and check if rbenv shims directory appears correctly in PATH and that it has precedence over system paths? |
I'm not sure where I would, in my own terminal window the shims path will of course be higher up. The problem is the context of what Pow is doing. It shows that the System ruby is being used meaning it is never executing thing in my zshrc. Basically just like my terminal before moving things to zshrc vs zshenv. If I comment out |
@metaskills You can run that command in your own terminal window because it will start a new environment within and ignore the calling environment. So it doesn't matter that the PATH in your terminal is already set up. Also, if you pass |
Thanks @mislav I did indeed see the shims path way up at the top of my path above system ones. Does that tell you anything? Still can only get Pow working with my hack above. |
Hm, not sure what's wrong in Pow then. Which version do you use? You can always create a page in your webapp that echoes |
@mislav 👍 |
After installing zsh i too had issue with switching ruby version under 10.11 El capitan I added this line into my .zshrc file eval "$(rbenv init -)" and restarted terminal was able to switch versions. Thanks @mislav |
@alec-c4 I'm sorry that we hijacked your original report to talk about unrelated issues. Do you still have the original problem of running |
@mislav Sorry, I'm a newbie here. Would you please tell me how I should modify /etc/zprofile?
|
@Prajna Your I'm closing this issue since this is a user configuration issue and nothing I can do from rbenv. |
This is the recommended location for setting the zsh path (https://sf.net/p/zsh/code/ci/master/tree/StartupFiles/zshenv), and problems arise with macOS El Capitan and later when set in zshenv. This problem is discussed in thoughtbot/dotfiles#426 and rbenv/rbenv#781. This also allows reverting a previous commit (08d13a0) that disabled global zsh config files.
Based on rbenv/rbenv#781 it seems that there is confusion on where PATH should be set. zsh suggests zshenv and also suggests NOT zshenv. Consensus seems to be use zshrc.
Hi,
After installation of gems like rails and bundle, that need to share their executables in shims directory and running rbenv rehash - nothing happens, there are no executables in shims directory :(
The text was updated successfully, but these errors were encountered: