Reputation: 1724
I've got Rails 3.0.10 and 3.1 installed because I am trying to use both for two different projects.
In my Rails 3.0.10 project, I have the following at the top of my Gemfile:
gem 'rails', '3.0.10'
However, after running bundle install; bundle exec rails --version
, I'm getting the following:
/Users/bradley/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/bundler-1.0.21/lib/bundler/runtime.rb:31:in `setup': You have already activated activesupport 3.1.1, but your Gemfile requires activesupport 3.0.10. Using bundle exec may solve this. (Gem::LoadError)
from /Users/bradley/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/bundler-1.0.21/lib/bundler/runtime.rb:17:in `setup'
from /Users/bradley/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/bundler-1.0.21/lib/bundler.rb:110:in `setup'
from /Users/bradley/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/bundler-1.0.21/lib/bundler/cli.rb:340:in `exec'
from /Users/bradley/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/bundler-1.0.21/lib/bundler/vendor/thor/task.rb:22:in `send'
from /Users/bradley/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/bundler-1.0.21/lib/bundler/vendor/thor/task.rb:22:in `run'
from /Users/bradley/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/bundler-1.0.21/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
from /Users/bradley/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/bundler-1.0.21/lib/bundler/vendor/thor.rb:263:in `dispatch'
from /Users/bradley/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/bundler-1.0.21/lib/bundler/vendor/thor/base.rb:386:in `start'
from /Users/bradley/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/bundler-1.0.21/bin/bundle:13
from /Users/bradley/.rbenv/versions/ree-1.8.7-2011.03/bin/bundle:19:in `load'
from /Users/bradley/.rbenv/versions/ree-1.8.7-2011.03/bin/bundle:19
Any ideas? Obviously, I'm already using bundle exec
and bundle show rails; bundle show activesupport
confirm that I should be using the right versions of the gems. Do I just need to uninstall Rails 3.1?
Upvotes: 1
Views: 1725
Reputation: 9501
I've run into the same problem.
Even when I explicitly specify the version of activesupport to use in my Gemfile:
gem 'rails', '3.2.9'
gem 'activesupport', '3.2.9'
it still gives me this error when I run bundle exec rails s
:
/home/tyler/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.0.18/lib/bundler/runtime.rb:31:in `block in setup':
You have already activated activesupport 3.2.10, but your Gemfile requires activesupport 3.2.9. Consider using bundle exec. (Gem::LoadError)
This happens for me when I want to try going back to an older version of Rails in my app to test a difference between the two versions of Rails.
So even creating a separate gemset for my app (which we usually do anyway) does not solve the problem, because the gemset was "polluted" by this app itself (by temporarily installing/using Rails 3.2.10 before going back to Rails 3.2.9), not by some other app!
The only solution I've found so far is to uninstall the newer version that you don't want it to use:
gem uninstall activesupport -v 3.2.10
It seems like this is either a bug in Bundler or a bug in Rails (if it does something that causes activesupport to be loaded/activated before it loads Bundler, then we can't really blame it on Bundler...).
Another equally terrible solution: To disable a newer version of a gem temporarily without uninstalling it, you can edit the gem's specification file (for example, /home/tyler/.rvm/gems/ruby-1.9.3-p194/specifications/activesupport-3.2.10.gemspec
) and add a line raise 'disabled'
at the top. Bundler will skip the loading of activesupport 3.2.10
(after rescuing and printing the error) and proceed to load the next highest version of activesupport
that it can find (activesupport 3.2.9
).
When you're ready to re-enable activesupport 3.2.10
, simply remove the raise
.
This may be quicker than uninstalling and reinstalling a gem, if you just want to test something with the older version before going back to the newer version of them gem.
Upvotes: 3
Reputation: 709
In my gem file, I changed the rails version to my current version:
gem 'rails', '3.2.2'
I executed the command: bundle update
And the error goes away
Upvotes: 1
Reputation: 5664
This may be off point, but please use Ruby Version Manager (RVM).
It will allow you to manage multiple ruby version installations as well as what is called gemsets which allow you to maintain global repos for all your gems (diff versions for each gem as well) and set which one you wish to use at any given time.
Aside from all that, look at cleaning up your installed gems and starting fresh:
gem clean -d # dry mode will simply tell you what will get cleaned
gem clean -v # will remove all older versions of every single gem
Other than that you can force remove the rails gem along with its dependencies (you can check what dependencies your rails version has)
gem uninstall actionmailer actionpack activerecord activesupport acriveresource rails -v=3.1.0
Hope that helps. Cheers!
Upvotes: 0
Reputation: 964
Create a '.rvmrc' file in each RAILS_ROOT dir (so at the root of each project)
fill it with:
vm_install_on_use_flag=1
rvm_gemset_create_on_use_flag=1
rvm use ruby-1.9.2-p290@APPNAME
where APPNAME is different for each app. CD out of the app dir and then back in. When you CD in, say yes to trusting the gem set. Then run Bundle install in each.
You created 2 gemsets, one for each project, so there is no cross-pollination of apps. This should fix the issues.
Upvotes: 0