Rails - 安装了最新的Gem,但应用程序已旧 [英] Rails - the newest gem is installed but the applicaiton is old

查看:99
本文介绍了Rails - 安装了最新的Gem,但应用程序已旧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Bluehost上工作。我安装了rails的3.2.8 gem,现在我得到了这个:

 >宝石名单 - 本地| grep rails 
rails(3.2.8)

但是:

  rails --version 
Rails 2.3.11

如何让rails命令使用最新的gem?我想这与我的$ PATH变量有关,但我对此几乎毫无头绪。

另外,gem和rails命令会产生一些错误,看起来像这样:

  [XXX]中的gemspec无效:规范中的无效日期格式:YYY
code>

我不确定这是否连接(我想知道是什么原因导致这样的错误)。

解决方案

试试运行这个命令:

  curl  - L https://get.rvm.io | bash -s stable --ruby --rails 

安装RVM,它维护独立的宝石为每个版本的Ruby安装。 - ruby​​ - rails 参数告诉它在安装RVM时安装ruby和rails。安装RVM会自动更新$ PATH和其他任何必需的环境变量。

在安装结束时,它应该提示您运行:

  source〜/ .rvm / scripts / rvm 



这将使这些环境变量的变化立即生效。或者,您可以注销并重新登录。



运行 rails -v ruby​​ -v ,你应该看到它们指向新版本。从你的RoR应用程序目录运行 bundle install ,你需要的所有宝石都应该安装在〜/ .rvm / gems / ruby​​- / gems中。



此时,您可以从安装RVM之前删除/卸载任何gems / rails / ruby​​。



编辑于10/17/2012:
Nevermind我的答案。尽管可能使Rails 3.x与当前安装的Ruby 1.8一起运行(请参阅此Stackoverflow问题),但您将无法使用Bluehost Shared Hosting运行Ruby 1.9.x。您唯一的选择就是VPS Hosting。



原因是Passenger Phusion与安装在/ usr / lib中的Ruby版本绑定,在没有root权限的情况下更改尽管你可以在RVM上安装任何版本的Ruby,但你不会让Passenger与它交谈,因此你的rails项目不会使用它的宝石。


I'm working on Bluehost. I installed the 3.2.8 gem of rails, and now I get this:

> gem list --local | grep rails
rails (3.2.8)

But:

rails --version
Rails 2.3.11

How can I make the "rails" command use the latest gem? I guess it has something to do with my $PATH variable but I'm pretty much clueless about it.

Also, the gem and rails command give rise to some errors that look like this:

Invalid gemspec in [XXX]: invalid date format in specification: "YYY"

I'm not sure if that's connected (and I'm wondering what causes such errors anyway).

解决方案

Try running this command:

curl -L https://get.rvm.io | bash -s stable --ruby --rails

What it does is install RVM, which maintains separate gems for each version of Ruby installed. The --ruby and --rails arguments tell it to install ruby and rails while installing RVM. RVM installation automatically updates $PATH and any other necessary environment variables.

At the end of installation, it should prompt you to run:

source ~/.rvm/scripts/rvm

which will make those environment variable changes effective immediately. Alternatively, you can log out and then log right back in.

Run rails -v and ruby -v at that point, and you should see them pointing to the new version. Run bundle install from your RoR app's directory and all the gems you need should install in ~/.rvm/gems/ruby-/gems.

At that point, you can delete/uninstall any gems/rails/ruby from before installing RVM.

EDIT on 10/17/2012: Nevermind my answer. Even though it might be possible to get Rails 3.x running with the currently installed Ruby 1.8 (see this Stackoverflow question), you won't be able to run Ruby 1.9.x using Bluehost Shared Hosting. Your only choice (for now) is VPS Hosting.

The reason is that Passenger Phusion is tied to the version of Ruby installed in /usr/lib, which you can't change without root access. Even though you can install any version of Ruby with RVM, you won't get Passenger to talk to it and therefore your rails project won't use its gems.

这篇关于Rails - 安装了最新的Gem,但应用程序已旧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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