如何从 Ruby 1.9.2 降级到 Ruby 1.8.7 以运行 Rails 2.0.2 [英] How to Downgrade from Ruby 1.9.2 to Ruby 1.8.7 to run Rails 2.0.2
问题描述
我想降级我在 Ubuntu 10.04 操作系统上安装的 Ruby 版本(Ruby 1.9.2),以便我可以使用适当版本的 Ruby 1.8.7 来运行 Rails 2.0.2.我将旧版本的 Rails 用于项目目的.
I want to downgrade the Ruby version I have installed(Ruby 1.9.2) on Ubuntu 10.04 OS so that I can use the appropriate version of Ruby 1.8.7 to run Rails 2.0.2. I am using the older version of Rails for project purpose.
如果我在 Ruby 1.9.2 中使用 Rails 2.0.2,它会给我一个错误,说无法将 Enumerator 转换为数组.
If I am using Rails 2.0.2 with Ruby 1.9.2 it gives me an error saying cant convert Enumerator into an array.
我认为我可以使用 rvm,但我不确定它是否适合降级.
I thought I could use rvm, but I am not sure if its suitable for downgrade.
当我使用命令 rvm list known
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 的路径.或者如果有其他方式请告诉我.
Do I need to uninstall Ruby 1.9.2 and only then freshly install Ruby 1.8.7 or can I switch versions?. If I can switch versions please direct me on how to set the path from Ruby 1.9.2 to Ruby 1.8.7. Or if there is some other way please let me know.
如果我必须卸载 Ruby 1.9.2,然后重新安装 Ruby 1.8.7,请告诉我该怎么做.我尝试了以下命令来卸载 Ruby 1.9.2,但似乎没有找到 Ruby 1.9.2 包.
If I have to uninstall Ruby 1.9.2 and then freshly install Ruby 1.8.7 please let me know how can I go about it. I tried the following commands to uninstall Ruby 1.9.2 but it didn't seem to find the Ruby 1.9.2 package.
sudo aptitude remove ruby
sudo aptitude remove ruby 1.9.2p0
sudo purge ruby
sudo aptitude purge ruby 1.9.2p0
当我检查当前安装的 Ruby 版本时,它显示:
When I checked for the current version of Ruby installed it shows:
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
感谢您的帮助...!!
Thanks for your help..!!
推荐答案
RVM 的全部意义在于,您可以拥有多个 Ruby 版本并在它们之间轻松切换..
Whole point of RVM is so that you can have multiple versions of Ruby and switch among them easily..
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 !
这篇关于如何从 Ruby 1.9.2 降级到 Ruby 1.8.7 以运行 Rails 2.0.2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!