由于遗留系统,我需要使用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 implode,(我认为)导致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和我的宝石安装等。
第一个问题,这个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是第一位的,怎么能这是固定的吗?
答案 0 :(得分:1)
RVM告诉你它不喜欢shell的配置。所以试试
rvm get stable --auto-dotfiles
正如它所暗示的那样。 RVM需要是shell配置中包含的最后一个东西,否则它的功能会受到后面加载的shell命令的影响。
如果你使用自制软件,我会做更新和医生。
答案 1 :(得分:0)
执行:
rvm implode
install rvm
一次。这应该可以解决问题。