heroku push error: "Could not detect rake tasks"

Update January 2020: Heroku has just removed the bundler version as of December to prevent these issues from occurring. They mention it in this article.

Original Post:

I took all these steps when trying to solve the same error:

remote: -----> Installing node-v10.15.3-linux-x64
remote: -----> Detecting rake tasks
remote: 
remote:  !
remote:  !     Could not detect rake tasks
remote:  !     ensure you can run `$ bundle exec rake -P` against your app
remote:  !     and using the production group of your Gemfile.
remote:  !     Activating bundler (2.0.1) failed:
remote:  !     Could not find 'bundler' (2.0.1) required by your /tmp/build_2e6c96ff8cd3ab115ee56c51d05c7a28/Gemfile.lock.
remote:  !     To update to the latest version installed on your system, run `bundle update --bundler`.
remote:  !     To install the missing version, run `gem install bundler:2.0.1`
remote:  !     Checked in 'GEM_PATH=/tmp/build_2e6c96ff8cd3ab115ee56c51d05c7a28/vendor/bundle/ruby/2.6.0', execute `gem env` for more information
remote:  !     
remote:  !     To install the version of bundler this project requires, run `gem install bundler -v '2.0.1'`
remote:  !
remote: /app/tmp/buildpacks/b7af5642714be4eddaa5f35e2b4c36176b839b4abcd9bfe57ee71c358d71152b4fd2cf925c5b6e6816adee359c4f0f966b663a7f8649b0729509d510091abc07/lib/language_pack/helpers/rake_runner.rb:106:in `load_rake_tasks!': Could not detect rake tasks (LanguagePack::Helpers::RakeRunner::CannotLoadRakefileError)

Which was happening when trying to deploy in the same way. I followed all the commands in the production environment that the error message provides and that still didn't solve it. My versions:

~/movie_list [master] $ ruby -v
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin18]
~/movie_list [master] $ bundler version
Bundler version 2.0.1 (2019-01-04 commit d7ad2192f)

The solution that worked for me finally came from this issue comment I found on bundler. In order to deploy, I had to remove

BUNDLED WITH
   1.17.1

from my gemfile.lock, and then use git push heroku master.


Sometimes Heroku throws an issue on deployment about assets. You can precompile assets and push it to Heroku.

RAILS_ENV=production bundle exec rake assets:precompile

Update:

In case of it doesn't work, make sure to add RAILS_SERVE_STATIC_FILES env. to yr server.

Make it enabled or true nor anything :)

Because in Rails <5.1 production.rb has

config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?

Heroku: App -> Settings -> "Reveal Config Vars"

Sample: enter image description here


I had the same issue and it Turns out that I had installed the latest bundler version (bundler-2.2.1) You can check your bundler version by:

  • bundle version

Heroku seems to work well with bundler version 2.1.4. (not sure why) In my case I had to downgrade to version 2.1.4 and make it the default.

In my Ubuntu 20.10 When I type:

  • gem uninstall bundler

It uninstalls bundler version 2.2.1 and I am left with bundler version 2.1.4 which is then declared as the default gem and can't be uninstalled and that's exactly what I wanted. So after that I went to my rails app,

  • Deleted Gemfile.lock
  • bundle install
  • git add .
  • git commit -m "Modified Gemfile.lock"
  • git push origin master
  • git push heroku master

And everything worked perfectly.