sstephenson/rbenv — Issue #119: zsh command hash table is stale with system ruby
Author: bricestacey
Created: 2011-10-11 21:38:36+00:00
State: open

I have a zsh script to setup dev environments that create tmux sessions and windows. (see http://pastie.org/2643820)

Occasionally zsh's command hash would still be pointing to the system ruby.

[master][~/code/ezpz] hash | grep ruby=
jruby=/Users/brice/.rbenv/shims/jruby
ruby=/usr/bin/ruby

[master][~/code/ezpz] env | grep PATH
PATH=/Users/brice/.rbenv/shims:/Users/brice/.rbenv/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/Users/brice/.rbenv/shims:/Users/brice/.rbenv/bin:/opt/local/bin:/usr/local/git/bin

[master][~/code/ezpz] ruby -v
ruby 1.8.7 (2010-01-10 patchlevel 249) [universal-darwin11.0]

[master][~/code/ezpz] which ruby
/usr/bin/ruby

[master][~/code/ezpz] /Users/brice/.rbenv/shims/ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.0.0]

Would it be a good idea to maybe include a call the builtin rehash after rbenv-init has been run? This seems to have solved my problem. I just do the following in .zshrc

export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
builtin rehash