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