heroku push error: “Could not detect rake tasks”

后端 未结 10 1193
离开以前
离开以前 2020-12-04 01:19

I\'m trying to deploy a basic app and it\'s not working. Using

git push heroku master 

I got this error message:

remote:          


        
相关标签:
10条回答
  • 2020-12-04 02:04

    You may also want to add PG Gem file in production in your gem file

    GemFile

    group :production do
     gem 'pg'
     gem 'rails_12factor'
    end
    
    group :development do
     gem 'sqlite3'
    end
    

    OR:

    # Use sqlite3 as the database for Active Record
    gem 'sqlite3', group: [:development, :test]
    
    gem 'rails_12factor', group: :production
    gem 'pg', group: :production
    

    Once you added that there save and run the following:

    Terminal

    gem install bundler
    bundle install
    git add .
    git commit -m "Some comment here..."
    git push heroku master
    
    0 讨论(0)
  • 2020-12-04 02:06

    Since this post came up repeatedly looking for my answer, hopefully this helps someone:

    I was getting a similar error on Heroku when deploying updates to an app that was already up and running. The build process wasn't finding basic commands. This is what my error message looked like:

    -----> Installing node-v12.16.2-linux-x64
    -----> 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.
     !     /tmp/build_a61ee567/bin/rake: line 1: require_relative: command not found
     !     /tmp/build_a61ee567/bin/rake: line 2: require: command not found
     !     /tmp/build_a61ee567/bin/rake: line 3: Rake.application.run: command not found
     !
    /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/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_a61ee567/bin/rake: line 1: require_relative: command not found
    /tmp/build_a61ee567/bin/rake: line 2: require: command not found
    /tmp/build_a61ee567/bin/rake: line 3: Rake.application.run: command not found
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/ruby.rb:1068:in `rake'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/rails4.rb:84:in `block (2 levels) in run_assets_precompile_rake_task'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/base.rb:190:in `log'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/rails4.rb:78:in `block in run_assets_precompile_rake_task'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/instrument.rb:18:in `block (2 levels) in instrument'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/instrument.rb:40:in `yield_with_block_depth'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/instrument.rb:17:in `block in instrument'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/vendor/ruby/heroku-18/lib/ruby/2.6.0/benchmark.rb:308:in `realtime'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/instrument.rb:16:in `instrument'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/base.rb:50:in `instrument'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/base.rb:46:in `instrument'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/rails4.rb:77:in `run_assets_precompile_rake_task'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/ruby.rb:112:in `block (2 levels) in compile'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/ruby.rb:1089:in `allow_git'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/ruby.rb:105:in `block in compile'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/instrument.rb:18:in `block (2 levels) in instrument'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/instrument.rb:40:in `yield_with_block_depth'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/instrument.rb:17:in `block in instrument'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/vendor/ruby/heroku-18/lib/ruby/2.6.0/benchmark.rb:308:in `realtime'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/instrument.rb:16:in `instrument'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/base.rb:50:in `instrument'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/base.rb:46:in `instrument'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/ruby.rb:94:in `compile'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/rails2.rb:62:in `block in compile'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/instrument.rb:18:in `block (2 levels) in instrument'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/instrument.rb:40:in `yield_with_block_depth'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/instrument.rb:17:in `block in instrument'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/vendor/ruby/heroku-18/lib/ruby/2.6.0/benchmark.rb:308:in `realtime'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/instrument.rb:16:in `instrument'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/base.rb:50:in `instrument'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/base.rb:46:in `instrument'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/rails2.rb:60:in `compile'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/rails3.rb:42:in `block in compile'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/instrument.rb:18:in `block (2 levels) in instrument'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/instrument.rb:40:in `yield_with_block_depth'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/instrument.rb:17:in `block in instrument'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/vendor/ruby/heroku-18/lib/ruby/2.6.0/benchmark.rb:308:in `realtime'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/instrument.rb:16:in `instrument'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/base.rb:50:in `instrument'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/base.rb:46:in `instrument'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/rails3.rb:41:in `compile'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/rails4.rb:41:in `block in compile'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/instrument.rb:18:in `block (2 levels) in instrument'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/instrument.rb:40:in `yield_with_block_depth'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/instrument.rb:17:in `block in instrument'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/vendor/ruby/heroku-18/lib/ruby/2.6.0/benchmark.rb:308:in `realtime'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/instrument.rb:16:in `instrument'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/base.rb:50:in `instrument'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/base.rb:46:in `instrument'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/rails4.rb:40:in `compile'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/bin/support/ruby_compile:20:in `block (2 levels) in <main>'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/base.rb:190:in `log'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/bin/support/ruby_compile:19:in `block in <main>'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/instrument.rb:35:in `block in trace'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/instrument.rb:18:in `block (2 levels) in instrument'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/instrument.rb:40:in `yield_with_block_depth'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/instrument.rb:17:in `block in instrument'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/vendor/ruby/heroku-18/lib/ruby/2.6.0/benchmark.rb:308:in `realtime'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/instrument.rb:16:in `instrument'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/instrument.rb:35:in `trace'
        from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/bin/support/ruby_compile:15:in `<main>'
     !     Push rejected, failed to compile Ruby app.
     !     Push failed
    

    Bundles, rakes, and starting the app all worked fine locally.

    Turns out it was an issue with an update in the ruby buildpack. I locked the buildpack version to an older version with the command heroku buildpacks:set https://github.com/heroku/heroku-buildpack-ruby#v215 -a appname and redeployed. All good after that.

    Heroku stack heroku-16 and ruby version 2.3.8

    0 讨论(0)
  • 2020-12-04 02:07

    In my case the error was bin/rake file.

        # frozen_string_literal: true
        #!/usr/bin/env ruby
        
        require_relative '../config/boot'
        require 'rake'
        
        Rake.application.run
    

    Heroku requires #!/usr/bin/env ruby on top, like this:

        #!/usr/bin/env ruby
        # frozen_string_literal: true
    
        require_relative '../config/boot'
        require 'rake'
        
        Rake.application.run
    

    Solved! o/

    0 讨论(0)
  • 2020-12-04 02:10

    TL;DR; Have gem "better_errors", gem "binding_of_caller", gem 'pry-byebug' in global scope of your Gemfile

    In my case it was because I moved these 3 gems from the global scope to development in my Gemfile:

    gem "better_errors"

    gem "binding_of_caller"

    gem 'pry-byebug'

    They should probably be only in the development scope, but there's something that I'm missing. So, moving them back outside of the development scope my deploy and rakes work correctly

    0 讨论(0)
提交回复
热议问题