我使用ruby 2.0
安装了rvm
。我是tmux
的新手。
我在使用此配置的.tmux.conf
中使用zsh
set-option -g default-shell /bin/zsh
set-option -g default-command "/bin/zsh -i"
我也在.zshrc
source /Users/mgpyone/.rvm/scripts/rvm
现在,当我在tmux
会话中尝试时,这些是配置。
which ruby
说/Users/mgpyone/.rvm/rubies/ruby-2.0.0-p0/bin/ruby
where ruby
返回
/Users/mgpyone/.rvm/rubies/ruby-2.0.0-p0/bin/ruby
/Users/mgpyone/.rvm/bin/ruby
/Users/mgpyone/.rvm/bin/ruby
但为什么gem env
显示我的Ruby executable
路径设置为系统路径而不是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
我无法运行rake
之类的东西,因为我认为它已经用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)
我该如何解决这个问题?
答案 0 :(得分:1)
启动tmux时,很可能设置了$ GEM_HOME或$ GEM_PATH。使用tmux继承这些环境变量时,无论rvm设置如何,其下包含的每个shell都会受到这些设置的影响。
检查tmux showenv -g GEM_HOME
(或GEM_PATH)