4

I've installed cucumber-rails gem into new Rails 4 application following https://github.com/cucumber/cucumber-rails#installation

But when I try to run it error occurs:

biske@biske:~/bla$ cucumber

cannot load such file -- rails (LoadError)
/usr/local/lib/site_ruby/1.9.1/rubygems/custom_require.rb:60:in 'require'
/usr/local/lib/site_ruby/1.9.1/rubygems/custom_require.rb:60:in 'rescue in require'
/usr/local/lib/site_ruby/1.9.1/rubygems/custom_require.rb:35:in 'require'
/usr/lib/ruby/gems/1.9.1/gems/cucumber-rails-1.3.1/lib/cucumber/rails.rb:3:in '<top (required)'
/usr/local/lib/site_ruby/1.9.1/rubygems/custom_require.rb:60:in 'require'
/usr/local/lib/site_ruby/1.9.1/rubygems/custom_require.rb:60:in 'rescue in require'
/usr/local/lib/site_ruby/1.9.1/rubygems/custom_require.rb:35:in 'require' /home/biske/bla/features/support/env.rb:7:in '<top (required)'
/usr/lib/ruby/gems/1.9.1/gems/cucumber-1.3.4/lib/cucumber/rb_support/rb_language.rb:122:in 'load'
/usr/lib/ruby/gems/1.9.1/gems/cucumber-1.3.4/lib/cucumber/rb_support/rb_language.rb:122:in 'load_code_file'
/usr/lib/ruby/gems/1.9.1/gems/cucumber-1.3.4/lib/cucumber/runtime/support_code.rb:180:in'load_file'
/usr/lib/ruby/gems/1.9.1/gems/cucumber-1.3.4/lib/cucumber/runtime/support_code.rb:83:in 'block in load_files!'
/usr/lib/ruby/gems/1.9.1/gems/cucumber-1.3.4/lib/cucumber/runtime/support_code.rb:82:in 'each'
/usr/lib/ruby/gems/1.9.1/gems/cucumber-1.3.4/lib/cucumber/runtime/support_code.rb:82:in 'load_files!'
/usr/lib/ruby/gems/1.9.1/gems/cucumber-1.3.4/lib/cucumber/runtime.rb:183:in 'load_step_definitions'
/usr/lib/ruby/gems/1.9.1/gems/cucumber-1.3.4/lib/cucumber/runtime.rb:42:in 'run!'
/usr/lib/ruby/gems/1.9.1/gems/cucumber-1.3.4/lib/cucumber/cli/main.rb:47:in 'execute!'
/usr/lib/ruby/gems/1.9.1/gems/cucumber-1.3.4/bin/cucumber:13:in '<top (required)' /usr/bin/cucumber:23:in 'load' /usr/bin/cucumber:23:in '<main'

This error complains about 7th line from features/support/env.rb file, which is:

require 'cucumber/rails'

What could be problem here?

Hannele
  • 9,301
  • 6
  • 48
  • 68
Иван Бишевац
  • 13,811
  • 21
  • 66
  • 93

3 Answers3

1

I've experienced this issue after upgrading cucumber-rails version up to 1.3.15.

First of all regenerate your cucumber configs (especially if you have updated some gems recently):

rails g cucumber:install

If it does not help try to run cucumber within a bundler using command:

bundle exec cucumber

or more convenient and technically identical command (works in my case on rails 4.1.1):

rake cucumber

Learn more about "bundle exec" command prefix: Use bundle exec rake or just rake?

Community
  • 1
  • 1
Darkside
  • 659
  • 8
  • 20
1

In my case, the problem was that the file env.rb that I had in features/support, was requiring a file it shouldn't have, or that didn't exist.

So, check features/support/env.rb edit out as many requires as you can and see if that helps.

Andrew Mackenzie
  • 5,477
  • 5
  • 48
  • 70
0

cd into the features folder then try to run cucumber your_feature_name.feature

Concorde
  • 87
  • 3
  • 1
    any idea why this makes it work, but running the same features file from the directory level up doesn't? Also when I do that, it runs the feature, but doesn't find the step-definitions which are in subfolder of features :-( – Andrew Mackenzie Oct 09 '15 at 16:49