4
votes

I have a Rails 2.3.11 app running on Heroku. However, rake tasks no longer work on Heroku:

rake aborted!
You have already activated rake 0.9.0, but your Gemfile requires rake 0.8.7. Consider using bundle exec.

Rake works fine locally. I specified rake 0.8.7 in my Gemfile:

gem 'rake', '0.8.7'

My Gemfile.lock file is part of my git repo (not gitignored). I checked my Gemfile.lock looking for mentions of rake 0.9.0, but could not find any.

It looks like Heroku is keeping a copy of rake 0.9.0, but I can't find a way to get rid of it. Here's the full trace:

$ heroku rake -T --trace
rake aborted!
You have already activated rake 0.9.0, but your Gemfile requires rake 0.8.7. Consider using bundle exec.
/usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:27:in `setup'
/usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/spec_set.rb:12:in `each'
/usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/spec_set.rb:12:in `each'
/usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:17:in `setup'
/usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler.rb:100:in `setup'
/app/config/../config/preinitializer.rb:16
/app/config/boot.rb:28:in `load'
/app/config/boot.rb:28:in `preinitialize'
/app/config/boot.rb:10:in `boot!'
/app/config/boot.rb:124
/usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
/app/Rakefile:4
/app/.bundle/gems/ruby/1.8/gems/rake-0.9.0/lib/rake/rake_module.rb:25:in `load'
/app/.bundle/gems/ruby/1.8/gems/rake-0.9.0/lib/rake/rake_module.rb:25:in `load_rakefile'
/app/.bundle/gems/ruby/1.8/gems/rake-0.9.0/lib/rake/application.rb:495:in `raw_load_rakefile'
/app/.bundle/gems/ruby/1.8/gems/rake-0.9.0/lib/rake/application.rb:78:in `load_rakefile'
/app/.bundle/gems/ruby/1.8/gems/rake-0.9.0/lib/rake/application.rb:129:in `standard_exception_handling'
/app/.bundle/gems/ruby/1.8/gems/rake-0.9.0/lib/rake/application.rb:77:in `load_rakefile'
/app/.bundle/gems/ruby/1.8/gems/rake-0.9.0/lib/rake/application.rb:61:in `run'
/app/.bundle/gems/ruby/1.8/gems/rake-0.9.0/lib/rake/application.rb:129:in `standard_exception_handling'
/app/.bundle/gems/ruby/1.8/gems/rake-0.9.0/lib/rake/application.rb:59:in `run'
/app/.bundle/gems/ruby/1.8/gems/rake-0.9.0/bin/rake:31
/usr/ruby1.8.7/bin/rake:19:in `load'
/usr/ruby1.8.7/bin/rake:19

It looks like the problem described in the question below, but I'd rather not create a new app like this person ended up doing:

Gem not uninstalling on Heroku

4

4 Answers

3
votes

The problem originated from the spork gem in my :test group. Heroku's tech support was helpful and directed me towards Bundler. I found this Bundler issue on GitHub, which turned out not to be a problem with Bundler, but actually an issue in spork. For some reason, spork forces rake to be installed and doesn't specify a version constraint, so it just uses the newest version (0.9.0 as of now).

My solution was excluding the :test and :development groups on Heroku, to prevent spork from being included in my bundle (spork is only used in the test environment, but I went ahead and excluded :development as well, for good measure):

$ heroku config:add BUNDLE_WITHOUT="development:test"

After reinstalling my bundle on Heroku, my rake tasks work again.

0
votes

I'm not sure exactly on the internals of heroku but give 'heroku bundle exec rake -T --trace', that should load the bundled rake version.

0
votes

Try to follow the steps Andrei gave in this post

=== EDIT ===

Sorry it didn't work. I guess that you have only one option left: send a ticket to Heroku staff

0
votes

I got around this by installing an older version of Rake as a gem. That way my application uses a version of rake it can use. In my gemfile:

gem 'rake', '~> 0.8.7'