如何从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

查看:877
本文介绍了如何从Ruby 1.9.2降级到Ruby 1.8.7以运行Rails 2.0.2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想降级已在Ubuntu 10.04 OS上安装的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.

如果我将Rails 2.0.2与Ruby 1.9.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列表

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 ruby​​

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆