我想降级我在Ubuntu 10.04操作系统上安装的Ruby版本(Ruby 1.9.2),以便我可以使用相应版本的Ruby 1.8.7来运行Rails 2.0.2.我正在使用旧版本的Rails作为项目目的.
如果我使用Rails 2.0.2与Ruby 1.9.2它给我一个错误,说不能将枚举器转换成一个数组.
我以为我可以使用rvm,但我不知道它是否适合降级.
当我使用已知的rvm命令时,我在终端中得到以下内容
mgj@pc146724-desktop:~$rvm list known # MRI Rubies [ruby-]1.8.6[-p399] [ruby-]1.8.6-head [ruby-]1.8.7[-p302] [ruby-]1.8.7-head [ruby-]1.9.1-p243 [ruby-]1.9.1[-p376] [ruby-]1.9.1-p429 [ruby-]1.9.1-head [ruby-]1.9.2-preview1 [ruby-]1.9.2-preview3 [ruby-]1.9.2-rc1 [ruby-]1.9.2-rc2 [ruby-]1.9.2[-p0] [ruby-]1.9.2-head ruby-head # JRuby jruby-1.2.0 jruby-1.3.1 jruby-1.4.0 jruby-1.5.1 jruby-1.5.2 /home/mohnish/.rvm/config/known
我使用命令dpkg -l |在安装的ruby软件包的列表中得到以下内容grep红宝石
mgj@pc146724-desktop:~$dpkg -l | grep ruby ii libdbm-ruby 4.2 DBM interface for Ruby ii libdbm-ruby1.8 1.8.7.249-2 DBM interface for Ruby 1.8 ii libgdbm-ruby 4.2 GDBM interface for Ruby ii libgdbm-ruby1.8 1.8.7.249-2 GDBM interface for Ruby 1.8 ii libopenssl-ruby 4.2 OpenSSL interface for Ruby ii libopenssl-ruby1.8 1.8.7.249-2 OpenSSL interface for Ruby 1.8 ii libreadline-ruby 4.2 Readline interface for Ruby ii libreadline-ruby1.8 1.8.7.249-2 Readline interface for Ruby 1.8 ii libruby1.8 1.8.7.249-2 Libraries necessary to run Ruby 1.8 ii libtcltk-ruby 4.2 Tcl/Tk interface for Ruby ii libtcltk-ruby1.8 1.8.7.249-2 Tcl/Tk interface for Ruby 1.8 ii rdoc 4.2 Generate documentation from ruby source file ii ruby 4.2 An interpreter of object-oriented scripting ii ruby-elisp 4.2 Emacs-lisp ruby-mode for Ruby ii ruby-full 4.2 Ruby full installation ii ruby1.8 1.8.7.249-2 Interpreter of object-oriented scripting lan ii ruby1.8-dev 1.8.7.249-2 Header files for compiling extension modules ii ruby1.8-elisp 1.8.7.249-2 ruby-mode for Emacsen mgj@pc146724-desktop:~$^C
我需要卸载Ruby 1.9.2,然后才刚刚安装Ruby 1.8.7或者我可以切换版本吗?如果我可以切换版本,请指导我如何设置从Ruby 1.9.2到Ruby 1.8.7的路径.或者如果还有其他方式请让我知道.
如果我必须卸载Ruby 1.9.2,然后安装Ruby 1.8.7,请让我知道如何解决.我尝试以下命令来卸载Ruby 1.9.2,但似乎没有找到Ruby 1.9.2包.
sudo aptitude remove ruby sudo aptitude remove ruby 1.9.2p0 sudo purge ruby sudo aptitude purge ruby 1.9.2p0
当我检查当前版本的Ruby安装它显示:
mgj@pc146724-desktop:~/Downloads/rubygems_postextract/rubygems-1.4.1$ruby -v ruby 1.9.2p0 (2010-08-18 revision 29036) [i686-linux] mgj@pc146724-desktop:~/Downloads/rubygems_postextract/rubygems-1.4.1$which ruby /home/mgj/.rvm/rubies/ruby-1.9.2-p0/bin/ruby
谢谢你的帮助..!!
解决方法
RVM的整体是这样的,您可以拥有多个版本的Ruby,并轻松切换.
rvm install 1.8.7 #or some specific version - choose from the rvm list known rvm use 1.8.7 rvm gemset create rails202 #create a gemset called "rails202" for Ruby 1.8.7 rvm 1.8.7@rails202 #make the gemset the current selection gem install rails -v 2.0.2 #install rails (just for this gemset!) #now,we have a gemset called "rails202" in Ruby 1.8.7. #anytime we want to use it,we do: rvm 1.8.7@rails202 #create as many gemsets needed,eg for rails 3.0.3 on Ruby 1.8.7 we can do the #similar as above. Then to use the new gemset just do: rvm 1.8.7@rails303 #et voila! we are now using Rails 3.0.3 on Ruby 1.8.7 !