简体   繁体   English

为什么 Rails 使用的是旧版本的 Ruby,即使我已经更新了它?

[英]Why is Rails using an old version of Ruby even though I have updated it?

I have an Ubuntu machine with Ruby 1.8 installed.我有一台安装了 Ruby 1.8 的 Ubuntu 机器。

I copied my Rails application to it, and did bundle install .我将我的 Rails 应用程序复制到其中,并进行了bundle install It installed everything fine.它安装一切正常。 The application requires Ruby 1.9, so I downloaded the Ruby source, compiled, and installed it.该应用程序需要 Ruby 1.9,所以我下载了 Ruby 源,编译并安装它。

When I do ruby -v , I get ruby 1.9.2p180 (2011-02-18 revision 30909) [i686-linux] , but when I do RUBY_VERSION on rails console , I get 1.8.7 .当我执行ruby -v时,我得到ruby 1.9.2p180 (2011-02-18 revision 30909) [i686-linux] ,但是当我在rails console上执行RUBY_VERSION 1.8.7时,我得到When I try to run my Rails application, it fails.当我尝试运行我的 Rails 应用程序时,它失败了。 My Rails application is using the older version of Ruby even when from the console and everywhere else it works fine.我的 Rails 应用程序使用的是旧版本的 Ruby,即使从控制台和其他任何地方都可以正常工作。 Heck, I even created a new Rails application and it uses a newer version.哎呀,我什至创建了一个新的 Rails 应用程序,它使用了更新的版本。

Any ideas what's going on?有什么想法吗?

Wait... you actually compiled it from source?等等...你实际上是从源代码编译的? You most likely have the new version of ruby in your console path but you application dosnt have it.您很可能在控制台路径中有新版本的 ruby,但您的应用程序没有它。 Uninstall ruby from your system and use RVM that way you have something managing your ruby versions.从您的系统中卸载 ruby 并使用 RVM,这样您就可以管理您的 ruby 版本。

type "which ruby" and "which irb"输入“which ruby”和“which irb”

you should see a path with ~/.rvm/ in it... but I bet you that you have somewhere on your system an old version of ruby and irb.. probably under /usr/bin您应该会看到一条带有 ~/.rvm/ 的路径...但我敢打赌,您的系统上某处有旧版本的 ruby 和 irb .. 可能在 /usr/bin 下

to get rid of this, you need to set your default ruby version in RVM and you need to make sure that RVM is setup correctly (eg in your.bashrc or.bash_profile file)要摆脱这种情况,您需要在 RVM 中设置默认 ruby 版本,并且您需要确保 RVM 设置正确(例如在 your.bashrc 或 .bash_profile 文件中)

type "rvm list".. and you should see something like this:键入“rvm list”.. 你应该会看到如下内容:

$ rvm list

rvm rubies

   ruby-1.8.7-p302 [ x86_64 ]
=> ruby-1.9.2-p0 [ x86_64 ]

NOTE: that you should see the arrow pointing to 1.9.2 which indicates it is the default version注意:您应该看到指向 1.9.2 的箭头,表示它是默认版本

if it is not set as default, type: "rvm --default use 1.9.2"如果未设置为默认值,请键入:“rvm --default use 1.9.2”

Also check "printenv PATH" to check that.rvm directories come before /usr/bin in the PATH还要检查“printenv PATH”以检查 .rvm 目录是否位于 PATH 中的 /usr/bin 之前

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

相关问题 即使定义了路线,为什么在Rails 3中也没有出现“路线错误”? - Why do I get No Route Error in Rails 3 even though I have defined a route? Ruby Rails webrick服务器使用旧版本的ruby - Ruby Rails webrick server using old version of ruby 即使我已允许,Rails为何仍会告诉我不允许的参数? - Why does Rails keep telling me unpermitted parameter even though I have permitted it? Aptana Studio滑轨使用旧的Ruby和Rials版本 - Aptana Studio rails using old Ruby , Rials Version 为什么Rails使用错误的Ruby版本? - Why is Rails using the wrong version of Ruby? Ruby on Rails:即使已安装gem仍未找到 - Ruby on Rails: gem not found even though it is installed Rails,即使我指定了方法 [POST] 或 [DELETE],为什么 link_to 总是使用方法 [GET] - Rails, why does link_to always use method [GET] even though I have specified method [POST] or [DELETE] 如何更新旧 Rails 项目上的 ruby​​ 版本 - How update the ruby version on a old rails project 如何在Cloud9上拥有旧版本的Ruby - How to have an old version of Ruby on Cloud9 Ruby on Rails-“需要”中:无法加载此类文件-omniauth / oauth,即使我安装了omniauth - Ruby on Rails - in 'require': cannot load such file — omniauth/oauth, even though I installed omniauth
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM