您的 Ruby 版本是 2.0.0,但您的 Gemfile 指定了 2.1.0
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23039528/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Your Ruby version is 2.0.0, but your Gemfile specified 2.1.0
提问by stecd
When I try to bundle install I get the following message:
当我尝试捆绑安装时,我收到以下消息:
Your Ruby version is 2.0.0, but your Gemfile specified 2.1.0
In my Gemfile I have the following:
在我的 Gemfile 中,我有以下内容:
ruby '2.1.0'
And when I run ruby -vin the console I get:
当我ruby -v在控制台中运行时,我得到:
ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin12.0]
What does Ruby 2.1.0p0 mean? What version should I have in my Gemfile and why does the error tell me I have Ruby version 2.0.0?
Ruby 2.1.0p0 是什么意思?我的 Gemfile 中应该有什么版本,为什么错误告诉我我有 Ruby 版本 2.0.0?
回答by Зелёный
Run
跑
gem install bundler
or
或者
gem update bundler
which may fix your problem.
这可能会解决您的问题。
For all new installed versions of Ruby you should update or install a new bundler.
对于所有新安装的 Ruby 版本,您应该更新或安装新的捆绑程序。
回答by Clay Bridges
In the top-level directory of your project, create a file named .ruby-versioncontaining (wait for it...)
在你的项目的顶级目录中,创建一个名为.ruby-versioncontains ( wait for it...)
2.1.0
That apparently is the cross-{rbenv,rvm}way of spec'ing the version now.
这显然是{rbenv,rvm}现在规范版本的交叉方式。
回答by Myers Carpenter
回答by Juan José Ramírez
For me, none of the answers helped. I fixed it closing and opening again the terminal.
对我来说,所有答案都没有帮助。我修复了它关闭并再次打开终端。
回答by Karen
None of the other suggestions was working for me. On the server, I had to do:
没有其他建议对我有用。在服务器上,我必须这样做:
rvm --default use [correct version number]
rvm --default use [correct version number]
回答by ethicalhack3r
brew cleanup rubyworked for me as I use HomeBrew to install Ruby.
brew cleanup ruby在我使用 HomeBrew 安装 Ruby 时对我来说有效。
I recently updated Ruby through HomeBrew but HomeBrew did not remove the older version. brew cleanup rubywill delete the older version of Ruby.
我最近通过 HomeBrew 更新了 Ruby,但 HomeBrew 没有删除旧版本。brew cleanup ruby将删除旧版本的 Ruby。
回答by Darme
If you are using Capistrano you should also check your deploy.rbfile for the set :rbenv_rubyconfiguration.
如果您使用 Capistrano,您还应该检查您的deploy.rb文件的set :rbenv_ruby配置。
回答by mahemoff
I got this after upgrading with ruby-install. Fixed this with:
使用ruby-install升级后我得到了这个。修复了这个:
gem install bundler
followed by:
其次是:
$HOME/.rubies/ruby-2.4.1/bin/bundle
It shouldn't be necessary to specify the path as which bundleindicates it's already using this path. But it gives the version error if running bundlewithout the path. I don't know why?
不需要指定路径,which bundle表示它已经在使用此路径。但是如果在bundle没有路径的情况下运行,它会给出版本错误。我不知道为什么?
回答by Thiemo
If you are using rbenv to manage your ruby environments you can run rbenv local 2.1.0within your project directory to set the version of ruby your gemfile asks for.
如果您使用 rbenv 来管理您的 ruby 环境,您可以rbenv local 2.1.0在您的项目目录中运行以设置您的 gemfile 要求的 ruby 版本。
回答by Ken Ratanachai S.
This could happen when you install new version of ruby and update .ruby-version and Gemfile to the new version without doing install all the gems for new version of ruby first. So do the
当您安装新版本的 ruby 并将 .ruby-version 和 Gemfile 更新到新版本而不先为新版本的 ruby 安装所有 gem 时,可能会发生这种情况。所以做
$ bundle install
and you might as well need to source .profile or restart your shell.
并且您可能还需要获取 .profile 或重新启动您的 shell。

