You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The output of :!echo $PATH might be useful. I wonder where chruby's paths are?
Another thing to try (on OS X) is sudo mv /etc/{zshenv,zshrc} which fixes a weird OS X bug that tends to mangle $PATH when you spawn new login shells (lifted from thoughtbot/laptop)
If you have administrator privileges, you must fix an Apple miss
configuration in Mac OS X 10.7 Lion by renaming /etc/zshenv to
/etc/zprofile, or Zsh will have the wrong PATH when executed
non-interactively by scripts.
I'm pretty sure when I had the same problem as you, doing sudo mv /etc/zshenv /etc/zprofile and restarting vim/tmux/zsh/iTerm2 fixed it.
@myronmarston chruby is definitely modifying PATH, but it appears that your shell configuration is blindly prepending /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin before the ruby's bin/. Double check your shell configuration, also I have seen issues before where OSX's path_helper messes with PATH when spawning sub-shells.
/etc/zshenv calls eval $(/usr/libexec/path_helper -s) which rebuilds (and re-orders) the path.
From the path_helper man page:
The path_helper utility reads the contents of the files in the directories
/etc/paths.d and /etc/manpaths.d and appends their contents to the PATH and
MANPATH environment variables respectively.
Prior to reading these directories, default PATH and MANPATH values are
obtained from the files /etc/paths and /etc/manpaths respectively.
/etc/manpaths respectively.
And from the Zsh man pages:
Commands are first read from /etc/zshenv; this cannot be overridden.
…
As /etc/zshenv is run for all instances of zsh, it is important that it be kept as small as possible.
…
If the shell is a login shell, commands are read from /etc/zprofile and then
$ZDOTDIR/.zprofile. Then, if the shell is interactive, commands are read from
/etc/zshrc and then $ZDOTDIR/.zshrc. Finally, if the shell is a login shell,
/etc/zlogin and $ZDOTDIR/.zlogin are read.
… So Mac OS's path mangling should really only be done for login shells, otherwise the PATH environment doesn't survive sub-shells. That means /etc/zprofile should be ideal. But if for some reason you only want it on interactive login shells, /etc/zshrc would also work. But never /etc/zshenv.
Thanks for all the help, everyone...it's nice to get some prompt help :).
This is definitely an area where my understanding is lacking; I need to get better. I tried the mvs suggested above and it's not helping, unfortunately. However, if I remove the set shell=$SHELL\ -l from my vim config (as recommended by the wiki), it works fine. Go figure.
Still don't quite understand it, but at least I've got it working now.
@myronmarston The mv alone didn't have effect since you had $SHELL -l in your vimrc. The -l flag means you opted in to boot the shell in login mode, which means that the new /etc/zprofile (after having done mv) would get sourced.
Generally, you probably never want -l when starting a shell until you have a strong reason why you want the shell to start in login mode.
@postmodern i've been wrestling with $SHELL\ -l, and it doesn't really make much sense when you think about it (login shells are only supposed to be invoked once, when you "log in"). using set shell=$SHELL works fine for me, after renaming /etc/zshenv to /etc/zprofile.
@tubbo I forced the -l option so the login configuration would be loaded (I have chruby configured in /etc/profile.d/chruby.sh). I suppose vim was default to using dash or bash, when you wanted zsh?
Activity
alindeman commentedon Sep 4, 2013
The output of
:!echo $PATHmight be useful. I wonder wherechruby's paths are?Another thing to try (on OS X) is
sudo mv /etc/{zshenv,zshrc}which fixes a weird OS X bug that tends to mangle $PATH when you spawn new login shells (lifted from thoughtbot/laptop)pda commentedon Sep 4, 2013
Are you running zsh via homebrew?
Note this part of the Caveats for
brew info zsh:I'm pretty sure when I had the same problem as you, doing
sudo mv /etc/zshenv /etc/zprofileand restarting vim/tmux/zsh/iTerm2 fixed it.myronmarston commentedon Sep 4, 2013
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/Users/myron/.gem/ruby/1.9.3/bin:/Users/myron/.rubies/ruby-1.9.3-p448/lib/ruby/gems/1.9.1/bin:/Users/myron/.rubies/ruby-1.9.3-p448/bin:/Users/myron/code/clusterpluck/support/ec2-api-tools-1.3-57419/bin
Trying the other suggestions now...
mislav commentedon Sep 4, 2013
You probably run zsh. You can set the shell to be
set shell=bashin Vim if you don't absolutely require zsh in Vim.The zsh problem is likely due to Mac OS X shipping with
/etc/zshenvwhich should be/etc/zprofile. Fix that with:This fixes more issues down the road than just Vim.
mislav commentedon Sep 4, 2013
Whoops, the guys above already said the same thing. Sorry for the noise!
postmodern commentedon Sep 4, 2013
@myronmarston chruby is definitely modifying PATH, but it appears that your shell configuration is blindly prepending
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/binbefore the ruby'sbin/. Double check your shell configuration, also I have seen issues before where OSX'spath_helpermesses withPATHwhen spawning sub-shells.pda commentedon Sep 4, 2013
For some background into the problem:
/etc/zshenvcallseval $(/usr/libexec/path_helper -s)which rebuilds (and re-orders) the path.From the path_helper man page:
And from the Zsh man pages:
… So Mac OS's path mangling should really only be done for login shells, otherwise the PATH environment doesn't survive sub-shells. That means
/etc/zprofileshould be ideal. But if for some reason you only want it on interactive login shells,/etc/zshrcwould also work. But never/etc/zshenv.postmodern commentedon Sep 4, 2013
See also: UNIX Shell Initialization.
pda commentedon Sep 4, 2013
Nice.
myronmarston commentedon Sep 4, 2013
Thanks for all the help, everyone...it's nice to get some prompt help :).
This is definitely an area where my understanding is lacking; I need to get better. I tried the
mvs suggested above and it's not helping, unfortunately. However, if I remove theset shell=$SHELL\ -lfrom my vim config (as recommended by the wiki), it works fine. Go figure.Still don't quite understand it, but at least I've got it working now.
postmodern commentedon Sep 4, 2013
@pda suggestion for improving the wiki for Vim integration? I use
set shell=$SHELL\ -lwith bash and/etc/profile.d/chruby.sh.alindeman commentedon Sep 4, 2013
pun?
myronmarston commentedon Sep 4, 2013
Not intentional, actually :).
pda commentedon Sep 4, 2013
I've done a few fresh Mac OS setups lately. Personally I just do this:
~/.ruby-versionfile.sudo mv /etc/{zshenv,zprofile}(I lost hours tracking that down the first time).My .vimrc has never had/needed any special shell support.
(I run vim ← zsh ← tmux ← zsh ← iTerm2, which may differ from other setups e.g. MacVim).
mislav commentedon Sep 5, 2013
@myronmarston The
mvalone didn't have effect since you had$SHELL -lin your vimrc. The-lflag means you opted in to boot the shell in login mode, which means that the new/etc/zprofile(after having donemv) would get sourced.Generally, you probably never want
-lwhen starting a shell until you have a strong reason why you want the shell to start in login mode.myronmarston commentedon Sep 5, 2013
Good to know. I was just following the Vim instructions in the wiki. Sounds like that should be changed...
tubbo commentedon Oct 3, 2013
@postmodern i've been wrestling with
$SHELL\ -l, and it doesn't really make much sense when you think about it (login shells are only supposed to be invoked once, when you "log in"). usingset shell=$SHELLworks fine for me, after renaming/etc/zshenvto/etc/zprofile.postmodern commentedon Oct 3, 2013
@tubbo I forced the
-loption so the login configuration would be loaded (I have chruby configured in/etc/profile.d/chruby.sh). I suppose vim was default to usingdashorbash, when you wantedzsh?tubbo commentedon Oct 3, 2013
yeah, it defaults to bash or sh right?
postmodern commentedon Oct 3, 2013
On Fedora's vim 7.4,
shelldefaults to/bin/bash.Fix zsh loading in Mac for MacVim.