Heroku push error: "Could not detect rake tasks" ( Rails 6.1 )

Viewed 1340

I have a "Rails 6.1.1" application. Whenever I'm trying to deploy it I'm getting this error -

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:  !     /tmp/build_05dae8c4/config/boot.rb:4:in `require': cannot load such file -- bootsnap/setup (LoadError)
remote:  !     from /tmp/build_05dae8c4/config/boot.rb:4:in `<top (required)>'
remote:  !     from /tmp/build_05dae8c4/bin/rake:3:in `require_relative'
remote:  !     from /tmp/build_05dae8c4/bin/rake:3:in `<main>'
remote:

I'm trying to deploy it using -

git push heroku master 

Here is my Gemfile -

source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '2.7.2'

gem 'rails', '~> 6.1.1'
gem 'puma', '~> 5.0'
gem 'sass-rails', '>= 6'
gem 'webpacker', '~> 5.0'
gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.7'
gem 'bcrypt', '~> 3.1.7'

gem 'bootsnap', '>= 1.4.4', require: false

group :development, :test do
  gem 'sqlite3', '~> 1.4'
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end

group :development do
  gem 'web-console', '>= 4.1.0'
  gem 'rack-mini-profiler', '~> 2.0'
  gem 'listen', '~> 3.3'
  gem 'spring'
end

group :test do
  gem 'capybara', '>= 3.26'
  gem 'selenium-webdriver'
  gem 'webdrivers'
end

gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

I just started building the app and I was trying to deploy it with a basic controller. I checked everything and it still gives me that message. It's working perfectly in localhost.

4 Answers
rake assets:precompile --dry-run

And then if you see errors solve it and then run

rake assets:precompile

I fixed with rake assets:precompile after reading this and this

I tried rake assets:precompile and specifying locked platforms as recommended by heroku.

This was my first deploy to heroku and I didn't set the RAILS_MASTER_KEY as a config variable before my first deploy. Once I set that, the deploy successfully went through.

Related