【发布时间】:2014-12-12 16:55:41
【问题描述】:
由于是遗留系统,我需要使用 Ruby v1.8.7-p374。我一直在使用 RVM 来使用那个版本的 Ruby,一切似乎都运行良好,直到发生了一些变化。
现在我的系统不会使用我在 RVM 中指定的 Ruby 版本。有没有办法在 Ruby 版本之间手动切换?
相关问题:“Can't change Ruby Version using RVM”
以下是一些相关信息:
$ rvm --default use ruby-1.8.7-p374
Using /Users/wroberts/.rvm/gems/ruby-1.8.7-p374
$ ruby -v
ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin13]
$ echo $PATH
/Users/wroberts/.rvm/gems/ruby-1.8.7-p374/bin:/Users/wroberts/.rvm/gems/ruby-1.8.7-p374@global/bin:/Users/wroberts/.rvm/rubies/ruby-1.8.7-p374/bin:/Users/wroberts/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/ant/bin:/usr/local/mysql/bin:/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/bin:/usr/local/apache-maven/apache-maven-3.2.3/bin:/usr/bin/chromedriver/bin:/Users/wroberts/dev/tools/flex:/usr/local/bin:/usr/bin:/usr/sbin
$ rvm list
rvm rubies
ruby-1.8.7-head [ i686 ]
=* ruby-1.8.7-p374 [ i686 ]
# => - current
# =* - current && default
# * - default
$ which ruby
/Users/wroberts/.rvm/gems/ruby-1.8.7-p374/bin/ruby
$ ls /Users/wroberts/.rvm/gems/ruby-1.8.7-p374/bin/ruby
/Users/wroberts/.rvm/gems/ruby-1.8.7-p374/bin/ruby
$ rvm info
RVM version 1.26.4 (master) is installed yet 1.26.4 (latest) is loaded.
Please do one of the following:
* 'rvm reload'
* open a new shell
* 'echo rvm_auto_reload_flag=1 >> ~/.rvmrc' # for auto reload with msg.
* 'echo rvm_auto_reload_flag=2 >> ~/.rvmrc' # for silent auto reload.
现在还有更多问题:
$ rvm install 1.8.7 --without-tcl --without-tk
Warning! PATH is not properly set up, '/Users/wroberts/.rvm/gems/ruby-1.8.7-p374/bin' is not at first place,
usually this is caused by shell initialization files - check them for 'PATH=...' entries,
it might also help to re-add RVM to your dotfiles: 'rvm get stable --auto-dotfiles',
to fix temporarily in this shell session run: 'rvm use ruby-1.8.7-p374'.
Warning! Requested ruby installation which requires another ruby available - installing ruby-1.8.7-p374 first.
Checking requirements for osx.
/usr/local/bin/brew: /usr/local/Library/brew.rb: /System/Library/Frameworks/Ruby.framework/Versions
/Current/usr/bin/ruby: bad interpreter: No such file or directory
/usr/local/bin/brew: line 28: /usr/local/Library/brew.rb: Undefined error: 0
ERROR: '/bin' is not writable - it is required for Homebrew, try 'brew doctor' to fix it!
Requirements installation failed with status: 1.
To proceed rvm requires a ruby-1.8.7-p374 compatible ruby is installed.
We attempted to install it automatically but it failed with status 1.
Please install it manually (or a compatible alternative) to proceed.
它正在工作——我的解决方法,还有一个问题
所以我做了 rvm 内爆,这(我认为)导致 ruby 不在 System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby 中。
所以每次我尝试安装 1.8.7 --without-tcl --without-tk 时,我的 brew 文件都有问题。
最后几个问题:
我检查了 brew 文件,在顶部它正在使用
#!/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby -W0
我把它改成了
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -W0
现在 brew 工作了,我能够安装 1.8.7 并执行 rvm --default 使用 ruby-1.8.7-p374 和我的 gem 安装等。
第一个问题,这个 hacky 解决方案对我来说是一个大问题,不是什么大问题,还是由于问题的愚蠢性而导致的未知领域?
第二个问题,每次我打开一个新的 bash shell ruby -v 都会给我(我相信)系统版本的 ruby:
$ ruby -v
ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin13]
$ which ruby
/usr/bin/ruby
但后来我设置了默认 rvm 并希望这会自动发生,
$ rvm --default use ruby-1.8.7-p374
Warning! PATH is not properly set up, '/Users/wroberts/.rvm/gems/ruby-1.8.7-p374/bin' is not at first place,
usually this is caused by shell initialization files - check them for 'PATH=...' entries,
it might also help to re-add RVM to your dotfiles: 'rvm get stable --auto-dotfiles',
to fix temporarily in this shell session run: 'rvm use ruby-1.8.7-p374'.
Using /Users/wroberts/.rvm/gems/ruby-1.8.7-p374
$ ruby -v
ruby 1.8.7 (2013-06-27 patchlevel 374) [i686-darwin13.4.
$ which ruby
/Users/wroberts/.rvm/rubies/ruby-1.8.7-p374/bin/ruby
它说我的路径设置不正确,但是如果你检查这篇文章的顶部,/Users/wroberts/.rvm/gems/ruby-1.8.7-p374/bin 首先是,怎么能这个要修吗?
【问题讨论】:
-
输入
which ruby并显示结果。然后ls /Users/wroberts/.rvm/gems/ruby-1.8.7-p374/bin -
看来这个
/Users/wroberts/.rvm/gems/ruby-1.8.7-p374/bin/ruby是链接,它坏了。但请显示ls -l /Users/wroberts/.rvm/gems/ruby-1.8.7-p374/bin -
你有奇怪的解释器位置,在我的 rvm 安装中它被放置到
~/.rvm/rubies -
请将
rvm info的输出附加到您的问题中。 -
检查您的目录中的
.rvmrc和其他RVM 配置文件。它们覆盖命令行设置。有关详细信息,请参阅“rvmrc files”和“Typical RVM Project Workflow”。