简体   繁体   English

我们可以安装两个不同版本的ruby并将它们映射到同一服务器上各自版本的rails吗?

[英]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.

相关问题 同一服务器上不同Ruby版本上的多个Rails应用 - Multiple Rails apps on different Ruby versions on the same server 为什么有不同的Ruby On Rails版本? - Why are there different Ruby On Rails versions? 具有不同的ruby和rails版本的rails的服务器设置选项 - Server setup option for rails with different ruby and rails versions 如何为具有不同Ruby版本的两个Rails应用程序创建服务器设置? - How do I create a server setup for two Rails apps with different Ruby versions? mac 上有两个不同的 ruby​​ 版本? - Two different ruby versions on mac? 如何在同一开发机器上运行不同的Ruby版本和Rails版本 - How to Run different Ruby versions and Rails version on same development machine 如何在具有不同Ruby / Rails版本的两个应用程序上工作? - How do I working on two apps with different Ruby/Rails versions? 如何安装不同版本的Rails并保留现有版本? - How can I install different versions of Rails and keep the existing ones? 一台服务器上的2个ruby应用程序具有不同的Ruby版本 - 2 ruby apps on one server with different Ruby versions 在 Rails 中,如何通过 ruby​​-install 在不同版本的 Ruby 上运行多个版本的 puma-dev? - In Rails, how do you have multiple versions of puma-dev running on different versions of Ruby via ruby-install?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM