Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wrong ruby executable path in Tmux session

Tags:

macos

ruby

rvm

tmux

I've installed ruby 2.0 by using rvm. I am new to tmux.

I am using zsh in the .tmux.conf with this config

set-option -g default-shell /bin/zsh 
set-option -g default-command "/bin/zsh -i"

also I've loaded rvm path in .zshrc

source /Users/mgpyone/.rvm/scripts/rvm

Now, These are the configs when I try within the tmux session.

which ruby says /Users/mgpyone/.rvm/rubies/ruby-2.0.0-p0/bin/ruby

where ruby returns as

/Users/mgpyone/.rvm/rubies/ruby-2.0.0-p0/bin/ruby 
/Users/mgpyone/.rvm/bin/ruby 
/Users/mgpyone/.rvm/bin/ruby

but why gem env shows my Ruby executable path is set to System path instead of rvm

RubyGems Environment:
  - RUBYGEMS VERSION: 2.0.3
  - RUBY VERSION: 2.0.0 (2013-02-24 patchlevel 0) [x86_64-darwin12.3.0]
  - INSTALLATION DIRECTORY: /Users/mgpyone/.rvm/gems/ruby-2.0.0-p0
  - RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
  - EXECUTABLE DIRECTORY: /Users/mgpyone/.rvm/gems/ruby-2.0.0-p0/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-12
  - GEM PATHS:
     - /Users/mgpyone/.rvm/gems/ruby-2.0.0-p0
     - /Users/mgpyone/.rvm/gems/ruby-2.0.0-p0@global
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
     - :benchmark => false
     - :sources => ["https://rubygems.org"]
  - REMOTE SOURCES:
     - https://rubygems.org

And I can't run things like rake because I think it went and execute with System Ruby.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby app.rb -s puma
app.rb:1:in `require': no such file to load -- sinatra (LoadError)
        from app.rb:1
        rake aborted!
        Command failed with status (1): [/System/Library/Frameworks/Ruby.framework/...]
        /Users/mgpyone/work/rb/fileserver/Rakefile:9
        (See full trace by running task with --trace)

How can I resolve this ?

like image 675
Ye Lin Aung Avatar asked Jun 24 '26 17:06

Ye Lin Aung


1 Answers

It is likely that you had $GEM_HOME or $GEM_PATH set when you started tmux. With tmux inheriting these environment variables, every shell that is contained under it will be affected with those settings regardless of rvm setup.

Check with tmux showenv -g GEM_HOME (or GEM_PATH)

like image 152
mislav Avatar answered Jun 27 '26 09:06

mislav



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!