您的Gemfile中出错,而Bundler无法继续

时间:2012-05-13 19:03:54

标签: ruby-on-rails

我只是设置我的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.

这是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

5 个答案:

答案 0 :(得分:23)

您正在运行Ruby 1.8,语法attribute:需要ruby 1.9。您需要更改

gem 'cucumber-rails', '1.2.1', require: false

gem 'cucumber-rails', '1.2.1', :require => false

或安装Ruby 1.9(可能使用RVM或rbenv)并再次运行bundle install。如果这是一个新项目,这将是一个更好的选择。

答案 1 :(得分:15)

在更新我的Ruby / Rails环境后,我遇到了同样的错误。

gem update bundler修复了它。

答案 2 :(得分:1)

我在使用rvm时遇到了类似的问题。这对我有用:

检查您使用rvm(在终端中)使用的导轨版本: ruby -v(在我的情况下打开了一个版本设置为ruby 1.8.7的新终端,你的可能不是)

切换到正确的ruby版本(在我的情况下,它应该是ruby 2.1.1,你的可能不是): rvm 2.1.1(这将ruby版本设置为2.1.1,替换为项目的ruby x.x.x)

尝试重新运行捆绑检查: 捆绑检查

你应该得到: Gemfile的依赖性得到满足

答案 3 :(得分:0)

上述答案对我不起作用,但在Gemfile中评论了capistrano宝石。

答案 4 :(得分:0)

如果您使用的是RVM,请检查您使用的是哪个gemset:rvm current

如果它说,例如,system,您可能需要选择正确的gemset(我做过)。如果您无法记住所调用的内容,请使用rvm list gemsets,然后使用rvm use [correct gemset]选择正确的宝石集。