Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby on Rails - error when running cucumber: You have already activated activesupport 3.2.1, but your Gemfile requires activesupport 3.1.0.

I know this question has been asked in one form or the another before, but I still can't get a working solution for this.

I'm taking the saas course offered online and the code is directly cloned from https://github.com/saasbook/hw3_rottenpotatoes

When I run cucumber from the command prompt

Using the default profile...
You have already activated activesupport 3.2.1, but your Gemfile requires activesupport 3.1.0. Using bundle exec may solve this. (Gem::LoadError)
/Users/chemin/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/bundler-1.0.21/lib/bundler/runtime.rb:31:in `block in setup'
/Users/chemin/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/bundler-1.0.21/lib/bundler/runtime.rb:17:in `setup'
/Users/chemin/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/bundler-1.0.21/lib/bundler.rb:110:in `setup'
/Users/chemin/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/bundler-1.0.21/lib/bundler/setup.rb:7:in `<top (required)>'
/Users/chemin/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:59:in `require'
/Users/chemin/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:59:in `rescue in require'
/Users/chemin/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
/Users/chemin/rails_projects/saas/hw3_rottenpotatoes/config/boot.rb:6:in `<top (required)>'
/Users/chemin/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
/Users/chemin/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
/Users/chemin/rails_projects/saas/hw3_rottenpotatoes/config/application.rb:1:in `<top (required)>'
/Users/chemin/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
/Users/chemin/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
/Users/chemin/rails_projects/saas/hw3_rottenpotatoes/config/environment.rb:2:in `<top (required)>'
/Users/chemin/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
/Users/chemin/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
/Users/chemin/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/cucumber-rails-1.3.0/lib/cucumber/rails.rb:7:in `<top (required)>'
/Users/chemin/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:59:in `require'
/Users/chemin/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:59:in `rescue in require'
/Users/chemin/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
/Users/chemin/rails_projects/saas/hw3_rottenpotatoes/features/support/env.rb:7:in `<top (required)>'
/Users/chemin/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/cucumber-1.1.9/lib/cucumber/rb_support/rb_language.rb:129:in `load'
/Users/chemin/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/cucumber-1.1.9/lib/cucumber/rb_support/rb_language.rb:129:in `load_code_file'
/Users/chemin/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/cucumber-1.1.9/lib/cucumber/runtime/support_code.rb:171:in `load_file'
/Users/chemin/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/cucumber-1.1.9/lib/cucumber/runtime/support_code.rb:83:in `block in load_files!'
/Users/chemin/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/cucumber-1.1.9/lib/cucumber/runtime/support_code.rb:82:in `each'
/Users/chemin/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/cucumber-1.1.9/lib/cucumber/runtime/support_code.rb:82:in `load_files!'
/Users/chemin/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/cucumber-1.1.9/lib/cucumber/runtime.rb:175:in `load_step_definitions'
/Users/chemin/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/cucumber-1.1.9/lib/cucumber/runtime.rb:40:in `run!'
/Users/chemin/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/cucumber-1.1.9/lib/cucumber/cli/main.rb:43:in `execute!'
/Users/chemin/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/cucumber-1.1.9/lib/cucumber/cli/main.rb:20:in `execute'
/Users/chemin/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/cucumber-1.1.9/bin/cucumber:14:in `<top (required)>'
/Users/chemin/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/bin/cucumber:19:in `load'
/Users/chemin/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/bin/cucumber:19:in `<main>'

after running bundle install version I get an even uglier message

Could not find rack-cache (~> 1.1) amongst [actionmailer-3.1.0, actionpack-3.1.0, activemodel-3.1.0, activerecord-3.1.0, activeresource-3.1.0, activesupport-3.1.0, addressable-2.2.7, archive-tar-minitar-0.5.2, arel-2.2.1, bcrypt-ruby-3.0.1, builder-3.0.0, capybara-1.1.2, childprocess-0.3.1, coffee-rails-3.1.1, coffee-script-2.2.0, coffee-script-source-1.2.0, columnize-0.3.6, cucumber-1.1.8, cucumber-rails-1.3.0, cucumber-rails-training-wheels-1.0.0, database_cleaner-0.7.1, diff-lcs-1.1.3, erubis-2.7.0, execjs-1.3.0, ffi-1.0.11, gherkin-2.8.0, haml-3.1.4, hike-1.2.1, i18n-0.6.0, jquery-rails-1.0.19, json-1.6.5, json_pure-1.6.5, launchy-2.0.5, libv8-3.3.10.4-x86_64-darwin-10, linecache19-0.5.12, mail-2.3.0, mime-types-1.17.2, multi_json-1.1.0, nokogiri-1.5.0, polyglot-0.3.3, rack-1.3.6, rack-cache-1.0.3, rack-mount-0.8.3, rack-ssl-1.3.2, rack-test-0.6.1, rails-3.1.0, railties-3.1.0, rake-0.9.2.2, rdoc-3.12, ruby-debug-base19-0.11.25, ruby-debug19-0.11.6, ruby_core_source-0.1.5, rubyzip-0.9.6.1, sass-3.1.15, sass-rails-3.1.5, selenium-webdriver-2.13.0, sprockets-2.0.3, sqlite3-1.3.5, term-ansicolor-1.0.7, therubyracer-0.9.10, thor-0.14.6, tilt-1.3.3, treetop-1.4.10, tzinfo-0.3.31, uglifier-1.2.3, xpath-0.1.4] (Gem::LoadError)
/Users/chemin/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs'
/Users/chemin/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:451:in `block in find_in_unresolved'
/Users/chemin/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:451:in `map'
/Users/chemin/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:451:in `find_in_unresolved'
/Users/chemin/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:43:in `require'
/Users/chemin/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/bundler-1.0.21/lib/bundler/dsl.rb:1:in `<top (required)>'
/Users/chemin/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/bundler-1.0.21/lib/bundler/definition.rb:17:in `build'
/Users/chemin/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/bundler-1.0.21/lib/bundler.rb:138:in `definition'
/Users/chemin/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/bundler-1.0.21/lib/bundler.rb:126:in `load'
/Users/chemin/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/bundler-1.0.21/lib/bundler.rb:110:in `setup'
/Users/chemin/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/bundler-1.0.21/lib/bundler/setup.rb:7:in `<top (required)>'
/Users/chemin/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:59:in `require'
/Users/chemin/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:59:in `rescue in require' 
/Users/chemin/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
/Users/chemin/rails_projects/saas/hw3_rottenpotatoes/config/boot.rb:6:in `<top (required)>'
/Users/chemin/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
/Users/chemin/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
/Users/chemin/rails_projects/saas/hw3_rottenpotatoes/config/application.rb:1:in `<top (required)>'
/Users/chemin/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
/Users/chemin/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
/Users/chemin/rails_projects/saas/hw3_rottenpotatoes/config/environment.rb:2:in `<top (required)>'
/Users/chemin/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
/Users/chemin/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
/Users/chemin/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/cucumber-rails-1.3.0/lib/cucumber/rails.rb:7:in `<top (required)>'
/Users/chemin/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:59:in `require'
/Users/chemin/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:59:in `rescue in require'
/Users/chemin/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
/Users/chemin/rails_projects/saas/hw3_rottenpotatoes/features/support/env.rb:7:in `<top (required)>'
/Users/chemin/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/cucumber-1.1.9/lib/cucumber/rb_support/rb_language.rb:129:in `load'
/Users/chemin/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/cucumber-1.1.9/lib/cucumber/rb_support/rb_language.rb:129:in `load_code_file'
/Users/chemin/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/cucumber-1.1.9/lib/cucumber/runtime/support_code.rb:171:in `load_file'
/Users/chemin/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/cucumber-1.1.9/lib/cucumber/runtime/support_code.rb:83:in `block in load_files!'
/Users/chemin/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/cucumber-1.1.9/lib/cucumber/runtime/support_code.rb:82:in `each'
/Users/chemin/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/cucumber-1.1.9/lib/cucumber/runtime/support_code.rb:82:in `load_files!'
/Users/chemin/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/cucumber-1.1.9/lib/cucumber/runtime.rb:175:in `load_step_definitions'
/Users/chemin/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/cucumber-1.1.9/lib/cucumber/runtime.rb:40:in `run!'
/Users/chemin/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/cucumber-1.1.9/lib/cucumber/cli/main.rb:43:in `execute!'
/Users/chemin/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/cucumber-1.1.9/lib/cucumber/cli/main.rb:20:in `execute'
/Users/chemin/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/cucumber-1.1.9/bin/cucumber:14:in `<top (required)>'
/Users/chemin/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/bin/cucumber:19:in `load'
/Users/chemin/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/bin/cucumber:19:in `<main>'
like image 952
James Lin Avatar asked Mar 12 '12 17:03

James Lin


2 Answers

There's a couple solutions, the easiest of which would be to try running bundle exec cucumber first, and see if that solves your problem.

If that doesn't work, delete your rails3tutorial gemset and re-create it again:

rvm gemset delete rails3tutorial
rvm 1.9.2-p290@rails3tutorial --create

Then run bundle, and hopefully it will install your gems for you. Follow this up with bundle exec cucumber (I almost always run my specs and cukes using bundle exec so that it doesn't try accidentally loading stale gems).

Hopefully this works!

UPDATE: Explaining bundle exec a little more

bundle exec is a command that bundler comes with that will run any other command in the context of your Gemfile. In this case, you're essentially telling it to run the cucumber command but only with the gems from your Gemfile, and not with all the gems currently available.

For instance, if you have previously installed activesupport 3.2.1, and your Gemfile asks for activesupport 3.1.0. When this happens I believe the cucumber command itself pulls in 'activesupport' (maybe via the require 'cucumber/rails' call in env.rb) which grabs any random version of activesupport it can (let's say it grabs 3.2.1) from your available gems. After this, it decides to load up your rails environment to start running your features. When it starts loading your actual app, the code looks at your Gemfile.lock and sees that what you actually want is activesupport 3.1.0, but it can't load an old version on top of a new version, so it crashes with the error James Lin pasted.

This is why, if you're using rvm, it's a good idea to keep separate gemsets for your separate projects, and delete/re-create the gemsets if you're updating your gems on that project so you don't keep old versions of gems around. Alternatively, bundle exec tends to solve 99% of the problems as well. If you aren't using rvm, and have multiple projects, then you probably have many different versions of many different gems, and you should always use bundle exec to do things like execute rake tasks, run cucumer features and other unit tests, etc.

like image 64
nzifnab Avatar answered Nov 18 '22 16:11

nzifnab


Or you could do bundle update to make sure all your gem plugins are the newest version and it will update your Gemfile.lock, so those two will be consistent.

I guess the difference between bundle exec and bundle update is whether you want bundle provide the version your app asking for or update your app gemfile so that the app wouldn't insist a stale version of gem when newer version installed and cause problem because the gem file.

Because when a version conflict happens, it is generally a good idea to make sure what installed in you system environment consistent with your app Gemfile or lock file as you don't want them trying to use an old version of gem when newer version available, unless you want freeze your gem system using rvm or similar at app level, but again, when you distribute you ruby app, it may cause problem in other machines.

In the end, because the need to distribute your app, unless newer version of gem file doesn't working with existing app, I think it shouldn't insist on an stale known-working version, unless you always want keep it on the safe side which is a valid argument.

like image 3
Paul L Avatar answered Nov 18 '22 16:11

Paul L