rbenv: The master branch of rbenv breaks inside of tmux.
When using the master branch version of rbenv, tmux no longer respects rbenv. For example I have global ruby setup to 2.0.0-p0 and when I run rbenv version
it correctly reports 2.0.0-p0, it is also correctly reported when I run ruby --version. Now in the same session I start a new tmux session using tmux new
. Now when I run rbenv version
it still correctly reports 2.0.0-p0, however when I run ruby --version
it now reports 1.8.7. When I run which ruby
it shows me /usr/bin/ruby
instead of the ruby shim.
About this issue
- Original URL
- State: closed
- Created 11 years ago
- Comments: 29 (10 by maintainers)
Commits related to this issue
- Change from rbenv to chruby (https://github.com/sstephenson/rbenv/issues/369) — committed to vnavarro/oh-my-zsh by vnavarro 10 years ago
- Switch back to freshshell/fresh for fresh bin; Add .git/safe to path - Fix bug with OS X zshenv: See https://github.com/sstephenson/rbenv/issues/369#issuecomment-33156619 and thread — committed to ericboehs/dotfiles by ericboehs 10 years ago
- FIX rbenv tmux bug see [This issue on rbenv](https://github.com/sstephenson/rbenv/issues/369) for more information — committed to djtal/dotfiles by djtal 10 years ago
- Fix rbenv PATH issue under tmux. https://github.com/sstephenson/rbenv/issues/369#issuecomment-36010083 — committed to larrylv/dotfiles by larrylv 10 years ago
- Add zprofile to handle path dup with tmux and rbenv See https://github.com/sstephenson/rbenv/issues/369 for more info — committed to mikeastock/dotfiles by mikeastock 10 years ago
- Fix the PATH issues w/ tmux once and for all See: sstephenson/rbenv#369 — committed to ciarand/phoenix by ciarand 10 years ago
- Load rbenv in zshrc, not zshenv On Mac OS X, there is a bug where `/etc/zshenv`'s `path_helper` forces `/usr/bin` to the front of the `$PATH`: https://github.com/sstephenson/rbenv/issues/369 # ... — committed to thoughtbot/dotfiles by deleted user 10 years ago
- Load rbenv in zshrc, not zshenv On Mac OS X, there is a bug where `/etc/zshenv`'s `path_helper` forces `/usr/bin` to the front of the `$PATH`: https://github.com/sstephenson/rbenv/issues/369 # ... — committed to thoughtbot/dotfiles by deleted user 10 years ago
- Fix test for adding shims in fish Commit e2173df4 (for issue #369) did not handle the fish test properly. This renames it and fixes the assertion. — committed to blueyed/rbenv by blueyed 9 years ago
- Correctly set PATH inside and outside of TMUX I noticed my `PATH` had duplicated entries in it. With help from a GitHub issue[1] and a comment[2] linking to another comment at StackOverflow[3] I unde... — committed to dawaa/dotfiles by dawaa 3 years ago
- Revert "Don't duplicate shims in PATH" Too many of our users have a shell initialization set up that inadvertently duplicates some or most of the entries in their PATH, bringing the system paths agai... — committed to AsherBond/rbenv by mislav 10 years ago
After a couple of hours of tinkering, the optimal way to solve this (without disabling
path_helper
entirely) is to make the following patch to/etc/zshenv
:The underlying problem is that all your shell configuration files are loaded twice when you create a tmux session/window. So the following happens:
/etc/zshenv
is loaded, which runs/usr/libexec/path_helper
, which sets your PATH variable.path_helper
runs again, putting stuff before your shims directory.This patch ensures that your shell configuration is loaded starting from a blank path. This has two benefits:
@mislav Thanks, good point.
I think I found a fix that works now. I’m running bash, and I wanted a solution that worked only for my current user (no messing with
/etc/profile
), so I ended up with a~/.bash_profile
which looks like this:Now my
$PATH
is the same with or withouttmux
.via http://superuser.com/a/583502
EDIT: Don’t do this. It sorts alphabetically, which you probably don’t want.
Running tmux + bash on OS X 10.9 with this in my
~/.profile
:via http://linuxg.net/oneliners-for-removing-the-duplicates-in-your-path/
It seems like tmux will always call the profile for your shell, not just the rc (I’m using bash, and it’s definitely calling /etc/profile, which also has a call to path_helper).
What I’m doing to fix it is changing
/etc/profile
to this:instead of