【发布时间】:2016-01-22 21:49:11
【问题描述】:
我有一个 Rails 应用程序,我是一个新的 Rails。
我的主要问题是我在生产服务器上,无法运行bundle。
它给出了这个错误:
Your Ruby version is 1.9.3, but your Gemfile specified 2.1.7
所以,我尝试使用 rbenv,但是如下所示,它并不成功。
$:/home/deploy/my-app/current$ rbenv global 2.1.7
$:/home/deploy/my-app/current$ bundle
Your Ruby version is 1.9.3, but your Gemfile specified 2.1.7
$:/home/deploy/my-app/current$ ruby -v
ruby 2.1.7p400 (2015-08-18 revision 51632) [x86_64-linux]
使用 RVM 似乎是其他人在其他问题中使用的,但我真的只想运行一个版本的 ruby(指定的那个)
此服务器将投入生产,但目前尚未上线。
编辑 1: gem install bundler
我曾尝试在 ruby 2.1.7 中安装 bundle,但这没有用。
这是我所做的:
$:/home/deploy/my-app/current$ ruby -v
ruby 2.1.7p400 (2015-08-18 revision 51632) [x86_64-linux]
$:/home/deploy/my-app/current$ gem install bundler
Fetching: bundler-1.11.2.gem (100%)
Successfully installed bundler-1.11.2
Parsing documentation for bundler-1.11.2
Installing ri documentation for bundler-1.11.2
Done installing documentation for bundler after 4 seconds
1 gem installed
$:/home/deploy/my-app/current$ bundle
Your Ruby version is 1.9.3, but your Gemfile specified 2.1.7
编辑 2 which bundle
$:/home/deploy/my-app/current$ which bundle
/usr/local/bin/bundle
【问题讨论】:
-
which bundle显示什么?可能是您在 2.1.7 中没有安装 Bundler,但它在 1.9.3 中(我怀疑是操作系统提供的 Ruby 版本),并且当您运行bundle时会找到此版本.您可能只需要在 2.1.7 中gem install bundler。 -
which bundle给出:/usr/local/bin/bundle @matt -
你使用 Bash 作为你的 shell 吗?安装 bundler 后,尝试运行
hash -r(或者启动一个新会话)。你的 shell 可能已经缓存了旧版本bundle的路径,所以你可能仍然得到它而不是新版本。 -
我认为这可能是问题所在,我最近才开始工作,我认为这是我重新启动终端的结果。 @马特
标签: ruby-on-rails ruby bundle