Skip to content

Could not detect rake tasks when deploying to heroku #21

@nickangtc

Description

@nickangtc

Referring to https://www.learnenough.com/course/ruby_on_rails_tutorial_6th_edition/beginning/deploying/heroku_commands_setup (private link).

This took me an hour to resolve, so I thought I'd share this here in case something could be done to save others some time.

the error message from push heroku

$ git push heroku master

...

remote: -----> Installing node-v16.13.1-linux-x64
remote: -----> Installing yarn-v1.22.17
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:  !     rake aborted!
remote:  !     TypeError: wrong argument type false (expected Symbol)
remote:  !     /tmp/build_c313571b/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/compile_cache/iseq.rb:13:in `to_binary'

the solution: specify ruby version in Gemfile

I noticed that Heroku's build process was using Ruby 3.0.0 by default because the ruby version wasn't specified in our Gemfile (as suggested in the tutorial to omit). You can also see 3.0.0 being used for detecting rake in the traceback above.

For me, adding this into my Gemfile:

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

ruby "2.7.5"

# ...

and then adding, committing, and pushing to heroku resolved the error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions