[英]Can we install two different versions of ruby and map them to respective versions of rails on the same server?
I have already installed Ruby 1.8.7 and Rails 2.3.8 which is working fine. 我已经安装了Ruby 1.8.7和Rails 2.3.8,它运行正常。
Now, I need to install Rails 3.2.8 in order to install a gem and my goal build the same compatible with Rails 2.3.8 based on how it is developed. 现在,我需要安装Rails 3.2.8才能安装gem,我的目标是根据它的开发方式构建与Rails 2.3.8相同的兼容性。
I tried installing Rails 3.2.8 using gem install rails -v=3.2.8 -include-dependencies 我尝试使用gem install rails -v = 3.2.8 -include-dependencies安装Rails 3.2.8
but to my surprise when I checked gem list rails , it shows only Rails 2.3.8 and I'm unable to create a new app using rails 3.2.8 test . 但令我惊讶的是,当我检查gem list rails时 ,它只显示Rails 2.3.8并且我无法使用rails 3.2.8 test创建一个新应用程序。
I'm not sure but I read that Rails > 3.0 doesn't work well with Ruby 1.8.7 and needs Ruby>1.9 我不确定,但我读到Rails> 3.0与Ruby 1.8.7不兼容,需要Ruby> 1.9
Rails 3.2 is compatible with Ruby 1.8.7. Rails 3.2与Ruby 1.8.7兼容。 What you could do is have a ruby version manager like RVM or Rbenv.
你可以做的是拥有像RVM或Rbenv这样的ruby版本管理器。 I use RVM but some people prefer Rbenv as it does not mess with your shell.
我使用RVM但有些人更喜欢Rbenv,因为它不会弄乱你的shell。
Using version managers will allow you to have different versions of ruby and with RVM you can create different gemsets for each specific version. 使用版本管理器将允许您拥有不同版本的ruby,使用RVM可以为每个特定版本创建不同的gemset。
EDIT Here's the link for the release notes for rails 3.2 http://guides.rubyonrails.org/3_2_release_notes.html 编辑这是rails 3.2发行说明的链接http://guides.rubyonrails.org/3_2_release_notes.html
EDIT 编辑
There's a couple of commands that you can use. 您可以使用几个命令。
rvm list
will list the versions of ruby you have installed. 将列出您已安装的ruby版本。
To install a version of ruby you'd do something like rvm install 1.9.3
to use that version you'd do something like rvm use 1.9.3
You can even specify patch levels and switch between different versions. 要安装ruby版本,你可以使用
rvm install 1.9.3
来使用该版本,你可以使用rvm use 1.9.3
你甚至可以指定补丁级别并在不同版本之间切换。
Now, rvm uses a concept of gemsets, to create a gemset you can set up an .rvmrc file in your project with the following command 现在,rvm使用gemsets的概念,创建一个gemset,您可以使用以下命令在项目中设置.rvmrc文件
rvm --create ruby-1.9.3-p286@some-project
it will create a set of gems called some-project
where you can install whatever gem versions you want. 它将创建一组名为
some-project
的宝石,您可以在其中安装所需的任何宝石版本。
Notice that command can be ran from the command line as well. 请注意,命令也可以从命令行运行。 That will separate all the gems per project and you can switch between gemsets as you would ruby versions.
这将分离每个项目的所有宝石,你可以像ruby版本一样在gemsets之间切换。 Then in whichever gemset you'd just run gem install rails and the version
然后在任何gemset中你只需运行gem install rails和版本
Your ruby version is good enough for both rails 2 & 3. 你的ruby版本足够用于导轨2和3。
Try to create new app like below: 尝试创建如下的新应用:
rails _3.2.8_ new appname
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.