简体   繁体   English

如何在不使用RVM的情况下指定Ruby for Rails的版本?

[英]How do I specify a version of Ruby for Rails without using RVM?

How do I specify a version of Ruby for Rails without using RVM ? 如何在不使用RVM的情况下指定Ruby for Rails的版本?

I am using Xubuntu 11.10, which comes with Ruby 1.8. 我正在使用Ruby 1.8随附的Xubuntu 11.10。 I have installed Ruby 1.9 package, and updated the alternatives so ruby -version returns ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux] . 我已经安装了Ruby 1.9软件包,并更新了替代版本,因此ruby -version返回ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux] Rails still seems to be using 1.8 however, so how can I tell it to use Ruby 1.9 instead? 但是,Rails似乎仍在使用1.8,因此如何告诉它使用Ruby 1.9? I don't want to uninstall Ruby 1.8 since that will remove a bunch of other stuff as well. 我不想卸载Ruby 1.8,因为那样也会删除很多其他东西。

I know similar SO questions have been answered with "use RVM". 我知道类似的问题已经用“使用RVM”回答了。 I can't do this - it has a dependency on libreadline-gplv2-dev package, which conflicts with libreadline-dev which r-base-dev depends on. 我无法执行此操作-它依赖libreadline-gplv2-dev软件包,该软件包与r-base-dev依赖的libreadline-dev冲突。

It seems I need to update the gem command to use the 1.9 version as well as ruby, then I can install rails through that. 看来我需要更新gem命令以使用1.9版本以及ruby,然后才能通过它安装rails。 But to install rails, I need the dev headers for ruby. 但是要安装rails,我需要ruby的dev标头。 The following commands should work for others: 以下命令应适用于其他命令:

sudo apt-get install ruby1.9.1 ruby1.9.1-dev
sudo update-alternatives --config ruby
sudo update-alternatives --config gem
sudo gem install rails

Changing versions of ruby is a routine if you work with several projects. 如果您使用多个项目,则更改红宝石的版本是很常规的。 If you can't use rvm, try rbenv . 如果您不能使用rvm,请尝试rbenv

It seems your rubygems environment is using ruby 1.8 whereas you want your rails app to run in 1.9. 看来您的rubygems环境使用的是ruby 1.8,而您希望Rails应用程序在1.9中运行。 You can find out by doing this: 您可以这样做:

$ ruby -version
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]

$ gem env | grep 'RUBY VERSION'
   - RUBY VERSION: 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]

Make sure your rubygems environment under which rails runs is running the version you want. 确保运行Rails的rubygems环境正在运行所需的版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM