Ruby-on-rails 您的 Gemfile 中出现错误,并且 Bundler 无法继续
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10574405/
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
error in your Gemfile, and Bundler cannot continue
提问by SilverNightaFall
I just setup my mac for development and used this exact gemfile previously and it worked fine. I am not sure what I am doing wrong.
我只是为开发设置了我的 mac,之前使用了这个确切的 gemfile,它运行良好。我不确定我做错了什么。
Victorias-MacBook-Pro:sample_app Victoria$ bundle --without production
/Users/Victoria/Sites/sample_app/Gemfile:38:in `evaluate': compile error
/Users/Victoria/Sites/sample_app/Gemfile:28: syntax error, unexpected ':', expecting kEND
gem 'cucumber-rails', '1.2.1', require: false
^ (SyntaxError)
/Library/Ruby/Gems/1.8/gems/bundler-1.1.3/lib/bundler/definition.rb:18:in `build'
/Library/Ruby/Gems/1.8/gems/bundler-1.1.3/lib/bundler.rb:135:in `definition'
/Library/Ruby/Gems/1.8/gems/bundler-1.1.3/lib/bundler/cli.rb:220:in `install'
/Library/Ruby/Gems/1.8/gems/bundler-1.1.3/lib/bundler/vendor/thor/task.rb:22:in `send'
/Library/Ruby/Gems/1.8/gems/bundler-1.1.3/lib/bundler/vendor/thor/task.rb:22:in `run'
/Library/Ruby/Gems/1.8/gems/bundler-1.1.3/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
/Library/Ruby/Gems/1.8/gems/bundler-1.1.3/lib/bundler/vendor/thor.rb:263:in `dispatch'
/Library/Ruby/Gems/1.8/gems/bundler-1.1.3/lib/bundler/vendor/thor/base.rb:386:in `start'
/Library/Ruby/Gems/1.8/gems/bundler-1.1.3/bin/bundle:13
/usr/bin/bundle:19:in `load'
/usr/bin/bundle:19
There was an error in your Gemfile, and Bundler cannot continue.
This is the gemfile
这是宝石文件
source 'https://rubygems.org'
gem 'rails', '3.2.3'
gem 'jquery-rails', '2.0.0'
gem 'bootstrap-sass', '2.0.0'
gem 'bcrypt-ruby', '3.0.1'
gem 'faker', '1.0.1'
gem 'will_paginate', '3.0.3'
gem 'bootstrap-will_paginate', '0.0.5'
group :development, :test do
gem 'mysql2'
gem 'rspec-rails', '2.9.0'
gem 'guard-rspec', '0.5.5'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '3.2.4'
gem 'coffee-rails', '3.2.2'
gem 'uglifier', '1.2.3'
end
group :test do
gem 'capybara', '1.1.2'
gem 'factory_girl_rails', '1.4.0'
gem 'cucumber-rails', '1.2.1', require: false
gem 'database_cleaner', '0.7.0'
gem 'guard-spork', '0.3.2'
gem 'spork', '0.9.0'
# gem 'rb-fsevent', '0.4.3.1', require: false
# gem 'growl', '1.0.3'
end
group :production do
gem 'pg', '0.12.2'
end
回答by deviousdodo
You're running Ruby 1.8 and the syntax attribute:requires ruby 1.9. You will need to change
您正在运行 Ruby 1.8,并且语法attribute:需要 ruby 1.9。你需要改变
gem 'cucumber-rails', '1.2.1', require: false
to
到
gem 'cucumber-rails', '1.2.1', :require => false
Or install Ruby 1.9 (maybe using RVM or rbenv) and run bundle installagain. This would be a much bettter option if it's a new project.
或者安装 Ruby 1.9(可能使用 RVM 或 rbenv)并bundle install再次运行。如果它是一个新项目,这将是一个更好的选择。
回答by weiphi
I got the same error after updating up my Ruby/Rails environment.
更新我的 Ruby/Rails 环境后,我遇到了同样的错误。
gem update bundlerfixed it.
gem update bundler修复。
回答by socialmatchbox
I just had a similar issue while using rvm. Here is what worked for me:
我在使用 rvm 时遇到了类似的问题。这是对我有用的:
Check to see what version of rails you are using with rvm (in terminal): ruby -v (in my case opened a new terminal with version set to ruby 1.8.7, yours may not be)
检查您在 rvm 中使用的 rails 版本(在终端中): ruby -v (在我的情况下,打开了一个版本设置为 ruby 1.8.7 的新终端,您的可能不是)
Switch to the correct ruby version (In my case it should be ruby 2.1.1, yours may not be): rvm 2.1.1 (this sets the ruby version to 2.1.1, replace with your project's ruby x.x.x)
切换到正确的 ruby 版本(在我的情况下它应该是 ruby 2.1.1,你的可能不是):rvm 2.1.1(这将 ruby 版本设置为 2.1.1,替换为您项目的 ruby xxx)
Try re-running bundle check: bundle check
尝试重新运行捆绑检查:捆绑检查
You should get: The Gemfile's dependencies are satisfied
你应该得到:满足 Gemfile 的依赖
回答by jman
The above-mentioned answers did not work for me, but commenting out capistrano gems in the Gemfile did.
上面提到的答案对我不起作用,但在 Gemfile 中注释掉 capistrano gems 做了。
回答by Choylton B. Higginbottom
If you are using RVM, check which gemset you are using: rvm current.
如果您正在使用RVM,支票宝石你使用:rvm current。
If it says, for example, system, you may need to select the correct gemset (I did). Use rvm list gemsetsif you can't remember what it's called, then select the correct gemset using rvm use [correct gemset].
例如,如果它说 ,则system您可能需要选择正确的宝石集(我选择了)。rvm list gemsets如果您不记得它叫什么,请使用,然后使用rvm use [correct gemset].

