heroku push error: “Could not detect rake tasks”

后端 未结 10 1192
离开以前
离开以前 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 01:50

    Might help someone in the futue, although I think I was recieving this error due to the specific nature I was deploying my application.

    For me,

    1. I didn't set the config ENV variables that where required in production before pushing.
    2. I didn't set the build packs required by certain gems to work (needed by gems such as Watir)

    After setting the buildpacks on heroku and setting the ENV variables needed in production I managed to get this working.

    So make sure that all ENV variables and buildpacks imported on heroku before deploying your repo to heroku.

    0 讨论(0)
  • 2020-12-04 01:55

    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:

    0 讨论(0)
  • 2020-12-04 01:56

    use the rbenv to install ruby 2.6.0

     rbenv install 2.6.0
    

    Then go to your project directory and set the ruby version

     rbenv local 2.6.0
    

    Remove the install bundlers

     gem uninstall bundler
    

    Then install the latest bundler,the following will install the latest bundler

     gem install bundler
    

    Then you are good to go.

    0 讨论(0)
  • 2020-12-04 01:58

    "Any failure in asset compilation will now cause the push to fail. For Rails 5 asset pipeline support see the Ruby Support page."

    The Rails asset pipeline provides an assets:precompile rake task to allow assets to be compiled and cached up front rather than compiled every time the app boots. There are two ways you can use the asset pipeline on Heroku. Compiling assets locally. Compiling assets during slug compilation.

    To compile your assets locally, run the assets:precompile task locally on your app. Make sure to use the production environment so that the production version of your assets are generated.

    Before you can compile your assets on Heroku, you’ll need to be able to compile them locally, run this command to debug your assets:

    RAILS_ENV=production bundle exec rake assets:precompile
    

    This should complete with no errors. Do NOT check in the assets into git after running this command if using Rails 3 as per Heroku's documentation.

    A public/assets directory will be created. Inside this directory you’ll find a manifest.yml which includes the md5sums of the compiled assets in Rails 3. In Rails 4 the file will be manifest-.json. Adding public/assets to your git repository will make it available to Heroku.

    git add public/assets
    git commit -m "vendor compiled assets"`
    

    Now when pushing, the output should show that your locally compiled assets were detected:

    -----> Preparing Rails asset pipeline
       Detected manifest.yml, assuming assets were compiled locally
    

    More help can be found here

    And here

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

    I'd been getting both

    Could not detect rake tasks

    and

    LoadError: cannot load such file

    Turns out I'd got case wrong on a require statment - works fine on Windows (case insensitive filesystem) but fails on Heroku with those errors (quite mis-leading when looking at the 'Could not detect rake tasks')

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

    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.

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