4

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

Community
  • 1
  • 1

4 Answers4

3

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.

  • how do you reinstall your bundle on heroku ? I just did what you suggested and re-pushed my app to heroku, but my rake still don't work... – Alex Jun 29 '11 at 23:07
  • @Alex: Make sure you see the line `Unresolved dependencies detected; Installing...` when you push your app. Otherwise, your bundle is not being reinstalled. I'm not sure there's a way to force the bundle to reinstall without changing the Gemfile, though. – Étienne Després Jul 02 '11 at 22:37
  • Thanks Etienne, I contacted Heroku in the meantime and they purged my gems, and next time I pushed it reinstalled everything properly and noe it works (after I added the bundle_without option). – Alex Jul 04 '11 at 02:42
0

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

Community
  • 1
  • 1
Lucas
  • 2,886
  • 1
  • 27
  • 40
  • Unfortunately, these instructions don't work on Heroku because there is no way (that I know of) to manually uninstall a gem like you would on a regular machine. – Étienne Després May 26 '11 at 21:55
0

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.

sprysoft
  • 1,468
  • 2
  • 11
  • 7
0

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'
edgerunner
  • 14,873
  • 2
  • 57
  • 69
  • It's generally a good solution, but in my case the older version of rake (0.8.7) was already specified in my Gemfile. The problem was related to the spork gem. – Étienne Després Jun 01 '11 at 15:30