Tuesday, November 22, 2011

"WARNING: Cucumber-rails required outside of env.rb. The rest of loading is being defered until env.rb is called." with Bundler prerelease (1.1)

Had a real 'fun' time (ie. not fun) getting around this error every time I tried to run 'bundle exec spork cucumber' (which would then die):
Using Cucumber

Preloading Rails environment
WARNING: Cucumber-rails required outside of env.rb.  The rest of loading is being defered until env.rb is called.
  To avoid this warning, move 'gem cucumber-rails' under only group :test in your Gemfile
Loading Spork.prefork block...
undefined method `allow_rescue=' for ActionController::Base:Class (NoMethodError)

I couldn't find any erroneous require's of cucumber-rails outside my :test group in my Gemfile, but eventually I stumbled across the solution in the comments of this pull request (for a separate issue).

I had to change the line in my Gemfile to:

gem "cucumber-rails", "~> 1.0", require: false

For the error message to go away, and spork to run properly. It seems to have been caused by a way the new (prerelease/1.1) version of Bundler loads gems - what a bitch (but it is a lot faster than the older versions, so I'm still using it).


9 comments: