背景
操作系统:Ubuntu 12.04
RVM 版本:1.18.16(稳定) 默认 ruby:ruby 1.9.3-p385(通过 rvm)
确认 RVM 工作正常且 .rvmrc 受信任
$ bash -lc 'cd /home/client1/websites/site1; ruby -v' - client1
ruby 1.9.3p385 (2013-02-06 revision 39114) [x86_64-linux]
$ bash -lc 'cd /home/client1/websites/site2; ruby -v' - client1
ruby 1.8.7 (2012-02-08 MBARI 8/0x6770 on patchlevel 358) [x86_64-linux], MBARI 0x6770, Ruby Enterprise Edition 2012.02
$ bash -lc 'rvm rvmrc trusted /home/client1/websites/site2/.rvmrc'
The rvmrc at '/home/client1/websites/site2/.rvmrc' is currently trusted.
所需效果
$ bash -c 'cd /home/client1/websites/site2; ruby -v' - client1
ruby 1.9.3p385 (2013-02-06 revision 39114) [x86_64-linux]
$ bash -c 'cd /home/client1/websites/site2; ruby -v' - client1
ruby 1.8.7 (2012-02-08 MBARI 8/0x6770 on patchlevel 358) [x86_64-linux], MBARI 0x6770, Ruby Enterprise Edition 2012.02
当前效果
$ bash -c 'cd /home/client1/websites/site2; ruby -v' - client1
ruby 1.9.3p385 (2013-02-06 revision 39114) [x86_64-linux]
$ bash -c 'cd /home/client1/websites/site2; ruby -v' - client1
ruby 1.9.3p385 (2013-02-06 revision 39114) [x86_64-linux]
尝试过的事情
放置:
[[ -s /usr/local/rvm/scripts/rvm ]] && . /usr/local/rvm/scripts/rvm
在以下文件中:
- ~/.bashrc,
- ~/.profile,
- ~/.bash_profile,
- /etc/bash.bashrc
好吧,在文件的最顶部,在其他任何事情都可能导致问题之前。
旁注:我尝试过使用 .ruby-version 方法,但它似乎也不起作用(感谢 mpapis on irc)