22

What does this env.rb error mean, pls?

root# rake db:migrate
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

The gemfile is here:

source 'http://rubygems.org'

gem 'rails', '3.1.0'

# Bundle edge Rails instead:
# gem 'rails',     :git => 'git://github.com/rails/rails.git'

# for Heroku deployment - as described in Ap. A of ELLS book
group :development, :test do
  gem 'sqlite3'
  gem 'ruby-debug19', :require => 'ruby-debug'
  gem 'cucumber-rails'
  gem 'cucumber-rails-training-wheels'
  gem 'database_cleaner'
  gem 'capybara'
  gem 'launchy'
end
group :production do
#  gem 'pg'
end

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'therubyracer'              
  gem 'sass-rails', "  ~> 3.1.0"
  gem 'coffee-rails', "~> 3.1.0"
  gem 'uglifier'
end

gem 'jquery-rails'

# Use unicorn as the web server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
gem 'haml'
Alpha01
  • 838
  • 6
  • 13

2 Answers2

53

that's just how bundler works, you need to add :require => false after gem 'cucumber-rails'. I have to say the error message is a bit misleading.

Bradley Priest
  • 7,438
  • 1
  • 29
  • 33
  • Actually, it's not misleading. It suggests that you create an isolated `:test` group with test gems, which is cleaner than adding `:require => false` on them, IMO. – Fábio Batista Mar 20 '12 at 06:38
  • 23
    I've found in my apps even having it inside a specific test group still produces this error, and the `:require => false` is the only way to make the error it disappear. YMMV – Bradley Priest Mar 20 '12 at 07:45
  • I had to also comment out 'guard-compass' to make it work in guard environment. Development worked fine with the re-organization of groups. – Ram on Rails Apr 09 '12 at 22:21
4

It is suggesting that you isolate your test gems on a :test group. Your Gemfile will then look somewhat like this:

group :development, :test do
  gem 'sqlite3'
  gem 'ruby-debug19', :require => 'ruby-debug'
  gem 'launchy'
end

group :test do
  gem 'cucumber-rails'
  gem 'cucumber-rails-training-wheels'
  gem 'database_cleaner'
  gem 'capybara'
end

Personally, I liked the gem's suggestion. We really don't need the test gems loaded on our development environment.

Fábio Batista
  • 25,002
  • 3
  • 56
  • 68