0
votes

SOLUTION: I was running ruby 2.6.6p146 with Bundler version 2.2.4. As per @thiebo's suggestion, I downgraded to Bundler 2.1.2 and it worked! Steps:

  1. $ gem uninstall bundler
  2. [then delete Gemfile.lock]
  3. $ gem install bundler --version '2.1.2'

I've tried these options, but nothing has worked: heroku push error: "Could not detect rake tasks"

I can indeed run bundle exec rake -P against my app

I tried rescuing the Rakefile, and putting rspec into production in my Gemfile: Heroku could not detect rake tasks (LoadError: cannot load such file -- rspec/core/rake_task)

I added 'rake' to the gemfile.

Tried adding gem 'rack-timeout': Heroku 'Could not detect rake tasks'

I also followed this thread to no avail: https://github.com/rubygems/bundler/issues/3640

Here's the error:

Bundle completed (36.93s)
Cleaning up the bundler cache.
Detecting rake tasks
!
! Could not detect rake tasks
! ensure you can run `$ bundle exec rake -P` against your app
! and using the production group of your Gemfile.
!     
[...] rubygems_integration.rb:460:in `block in replace_bin_path': can't find executable rake for gem rake. rake is not currently included in the bundle, perhaps you meant to add it to your Gemfile? (Gem::Exception) from /[...]ruby/2.6.0/gems/bundler-2.0.2/lib/bundler/rubygems_integration.rb:491:in `block in replace_bin_path' from ./vendor/bundle/bin/rake:29:in `<main>'
![...]helpers/rake_runner.rb:106:in `load_rake_tasks!': Could not detect rake tasks (LanguagePack::Helpers::RakeRunner::CannotLoadRakefileError)
ensure you can run `$ bundle exec rake -P` against your app
and using the production group of your Gemfile.
/tmp/build_dcccbbf6_/vendor/bundle/ruby/2.6.0/gems/bundler- 
2.0.2/lib/bundler/rubygems_integration.rb:460:in `block in replace_bin_path': can't find executable rake for gem rake. rake is not currently included in the bundle, perhaps you meant to add it to your Gemfile? (Gem::Exception)
from /tmp/build_dcccbbf6_/vendor/bundle/ruby/2.6.0/gems/bundler-2.0.2/lib/bundler/rubygems_integration.rb:491:in `block in replace_bin_path'
from ./vendor/bundle/bin/rake:29:in `<main>'
from /tmp/codon/tmp/buildpacks/63cff2a36c882a48324b4b7a5466efcada2e529a/lib/language_pack/ruby.rb:1035:in `rake'
from /tmp/codon/tmp/buildpacks/63cff2a36c882a48324b4b7a5466efcada2e529a/lib/language_pack/rails4.rb:84:in `block (2 levels) in run_assets_precompile_rake_task'
from /tmp/codon/tmp/buildpacks/63cff2a36c882a48324b4b7a5466efcada2e529a/lib/language_pack/base.rb:190:in `log'
from /tmp/codon/tmp/buildpacks/63cff2a36c882a48324b4b7a5466efcada2e529a/lib/language_pack/rails4.rb:78:in `block in run_assets_precompile_rake_task'
from /tmp/codon/tmp/buildpacks/63cff2a36c882a48324b4b7a5466efcada2e529a/lib/language_pack/instrument.rb:18:in `block (2 levels) in instrument'
from /tmp/codon/tmp/buildpacks/63cff2a36c882a48324b4b7a5466efcada2e529a/lib/language_pack/instrument.rb:40:in `yield_with_block_depth'
from /tmp/codon/tmp/buildpacks/63cff2a36c882a48324b4b7a5466efcada2e529a/lib/language_pack/instrument.rb:17:in `block in instrument'
from /tmp/tmp.9BjaQ6WXw6/lib/ruby/2.6.0/benchmark.rb:308:in `realtime'
from /tmp/codon/tmp/buildpacks/63cff2a36c882a48324b4b7a5466efcada2e529a/lib/language_pack/instrument.rb:16:in `instrument'
from /tmp/codon/tmp/buildpacks/63cff2a36c882a48324b4b7a5466efcada2e529a/lib/language_pack/base.rb:50:in `instrument'
from /tmp/codon/tmp/buildpacks/63cff2a36c882a48324b4b7a5466efcada2e529a/lib/language_pack/base.rb:46:in `instrument'
from /tmp/codon/tmp/buildpacks/63cff2a36c882a48324b4b7a5466efcada2e529a/lib/language_pack/rails4.rb:77:in `run_assets_precompile_rake_task'
from /tmp/codon/tmp/buildpacks/63cff2a36c882a48324b4b7a5466efcada2e529a/lib/language_pack/ruby.rb:111:in `block (2 levels) in compile'
from /tmp/codon/tmp/buildpacks/63cff2a36c882a48324b4b7a5466efcada2e529a/lib/language_pack/ruby.rb:1056:in `allow_git'
from /tmp/codon/tmp/buildpacks/63cff2a36c882a48324b4b7a5466efcada2e529a/lib/language_pack/ruby.rb:104:in `block in compile'
from /tmp/codon/tmp/buildpacks/63cff2a36c882a48324b4b7a5466efcada2e529a/lib/language_pack/instrument.rb:18:in `block (2 levels) in instrument'
from /tmp/codon/tmp/buildpacks/63cff2a36c882a48324b4b7a5466efcada2e529a/lib/language_pack/instrument.rb:40:in `yield_with_block_depth'
from [... a lot more lines like this]
! Push rejected, failed to compile Ruby app.
! Push failed

Big thanks, if anyone knows.

2
I had this problem and solved it by downgrading back to Ruby 2.7.0 and Bundler 2.1.2.thiebo
wow, after all these attempts, this is the one that did it! 🙏🏻Ryan Buckley

2 Answers

2
votes

The Short Answer

use a version of bundler that Heroku supports

  gem uninstall bundler
  gem install bundler --version '2.1.2'

  rm Gemfile.lock
  bundle install

  git add Gemfile.lock
  git commit -m "downgrade bundler to appease the Heroku gods"
  git push heroku

This problem seems to have happened before: https://github.com/rubygems/bundler/issues/7486

0
votes

I just had this problem and the official documentation worked for me:

Bundler 2.2.3+

An app’s Gemfile.lock that is generated with Bundler 2.2.3 locally may not work on Heroku unless the Linux platform is explicitly “locked”:

$ bundle lock --add-platform ruby
$ bundle lock --add-platform x86_64-linux
$ bundle install
$ git add . ; git commit -m "Bundler fix"