【问题标题】:heroku push error: "Could not detect rake tasks"heroku 推送错误:“无法检测到 rake 任务”
【发布时间】:2016-07-23 12:02:03
【问题描述】:

我正在尝试部署一个基本应用,但它不工作。使用

git push heroku master 

我收到此错误消息:

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:  !     LoadError: cannot load such file -- /tmp/build_a1cfcabff50107f84830d908386197b2/config/application
remote:  !     /tmp/build_a1cfcabff50107f84830d908386197b2/Rakefile:4:in `require'
remote:  !     /tmp/build_a1cfcabff50107f84830d908386197b2/Rakefile:4:in `<top (required)>'
remote:  !     /tmp/build_a1cfcabff50107f84830d908386197b2/vendor/bundle/ruby/2.2.0/gems/rake-11.1.2/lib/rake/rake_module.rb:28:in `load'
remote:  !     /tmp/build_a1cfcabff50107f84830d908386197b2/vendor/bundle/ruby/2.2.0/gems/rake-11.1.2/lib/rake/rake_module.rb:28:in `load_rakefile'
remote:  !     /tmp/build_a1cfcabff50107f84830d908386197b2/vendor/bundle/ruby/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:689:in `raw_load_rakefile'
remote:  !     /tmp/build_a1cfcabff50107f84830d908386197b2/vendor/bundle/ruby/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:94:in `block in load_rakefile'
remote:  !     /tmp/build_a1cfcabff50107f84830d908386197b2/vendor/bundle/ruby/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:176:in `standard_exception_handling'
remote:  !     /tmp/build_a1cfcabff50107f84830d908386197b2/vendor/bundle/ruby/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:93:in `load_rakefile'
remote:  !     /tmp/build_a1cfcabff50107f84830d908386197b2/vendor/bundle/ruby/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:77:in `block in run'
remote:  !     /tmp/build_a1cfcabff50107f84830d908386197b2/vendor/bundle/ruby/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:176:in `standard_exception_handling'
remote:  !     /tmp/build_a1cfcabff50107f84830d908386197b2/vendor/bundle/ruby/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:75:in `run'
remote:  !     /tmp/build_a1cfcabff50107f84830d908386197b2/vendor/bundle/ruby/2.2.0/gems/rake-11.1.2/bin/rake:33:in `<top (required)>'
remote:  !     vendor/bundle/bin/rake:16:in `load'
remote:  !     vendor/bundle/bin/rake:16:in `<main>'
remote:  !
remote: /app/tmp/buildpacks/ruby/lib/language_pack/helpers/rake_runner.rb:102:in `load_rake_tasks!': Could not detect rake tasks (LanguagePack::Helpers::RakeRunner::CannotLoadRakefileError)

bundle exec rake -P 似乎工作正常。

我的 Gemfile 没有什么特别的,我只是添加了 Bootstrap:

source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.5.1'

# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

gem 'bootstrap-sass' 
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
#postgreeSQL for Heroku deployment


group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug'
  gem 'sqlite3'
end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'


  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
end
group :production do
  gem 'pg'
  gem 'rails_12factor'
end
ruby "2.2.3"

嗯,我不明白为什么会这样,因为我有另一个项目正常工作。我检查了所有内容,它仍然给了我这个信息。

【问题讨论】:

  • 你也可以添加你的gem文件吗?
  • 是的,但我唯一添加的是 Bootstrap。我为一个(非常)简单的项目做了前端,从昨天开始尝试部署并收到错误消息...
  • 你能发一下吗?我想我知道出了什么问题
  • 尝试使用bundle update 更新您的gem,如果这不起作用,请确保您正确使用git git init -> git add . -> git commit -m "ready for production etc.." -> git push heroku master
  • @jvrn3 你能尝试运行这个RAILS_ENV=production bundle exec rake assets:precompile

标签: ruby-on-rails heroku


【解决方案1】:

我遇到了同样的问题,结果我安装了最新的捆绑程序版本 (bundler-2.2.1) 您可以通过以下方式检查您的捆绑程序版本:

  • 捆绑版本

Heroku 似乎与捆绑器版本 2.1.4 配合得很好。 (不知道为什么) 就我而言,我不得不降级到 2.1.4 版本并将其设为默认版本。

在我的 Ubuntu 20.10 中输入时:

  • gem 卸载捆绑器

它卸载了 bundler 2.2.1 版,我留下了 bundler 2.1.4 版,然后它被声明为默认 gem,无法卸载,这正是我想要的。所以在那之后我去了我的rails应用程序,

  • 已删除 Gemfile.lock
  • 捆绑安装
  • git 添加。
  • git commit -m "修改的 Gemfile.lock"
  • git push origin master
  • git push heroku master

一切都很完美。

【讨论】:

  • 同样的问题,使用 Rails 6.1,似乎只有降级捆绑器工作。感谢您的解决方案。
  • 你让我省了很多麻烦……真是奇怪的情况!再次感谢!
  • 即使在 Heroku 修复之后(来自另一个答案中的博伊德的文章),这仍然是一个问题,而且这个解决方案仍然有效。谢谢!
  • 这太棒了
【解决方案2】:

Heroku 有时会在部署资产时引发问题。您可以预编译资产并将其推送到 Heroku。

RAILS_ENV=production bundle exec rake assets:precompile

更新:

如果它不起作用,请确保添加 RAILS_SERVE_STATIC_FILES 环境。到你的服务器。

设为enabledtrueanything :)

因为在 Rails production.rb 中有

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

Heroku:应用程序 -> 设置 -> “显示配置变量”

示例:

【讨论】:

  • 想解释一下为什么会这样?在那之前我不能投票给你的答案,坦率地说很少有人会,所以答案应该帮助人们理解这个问题,而不仅仅是提供一行代码。
  • RAILS_ENV=production bundle exec rake assets:预编译这对我不起作用。真的没有任何效果。我还能尝试什么?
  • @dave 你的问题是什么?
  • (无法检测到 rake 任务确保您可以针对您的应用运行 $ bundle exec rake -P 并使用您的 Gemfile 的生产组。rake 中止!) ...这是我推送时遇到的错误appto heroku
  • 我在本地“RAILS_ENV=production bundle exec rake assets:precompile”上运行了这个,然后将应用推送到 heroku,但同样的事情发生了。
【解决方案3】:

2020 年 1 月更新:Heroku 刚刚从 12 月删除了捆绑程序版本,以防止出现这些问题。他们在this article 中提到了它。

原帖:

我在尝试解决相同错误时采取了所有这些步骤:

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)

尝试以相同方式部署时发生的情况。我遵循了错误消息提供的生产环境中的所有命令,但仍然没有解决它。我的版本:

~/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)

对我有用的解决方案终于来自我在 bundler 上找到的this issue comment。为了部署,我必须删除

BUNDLED WITH
   1.17.1

来自我的 gemfile.lock,然后使用 git push heroku master

【讨论】:

    【解决方案4】:

    “资产编译中的任何故障现在都会导致推送失败。有关 Rails 5 资产管道支持,请参阅 Ruby 支持页面。”

    Rails 资产管道提供 assets:precompile rake 任务,以允许预先编译和缓存资产,而不是在每次应用启动时编译。 您可以通过两种方式在 Heroku 上使用资产管道。 在本地编译资产。 在 slug 编译期间编译资产。

    要在本地编译您的资产,请在您的应用上本地运行 assets:precompile 任务。确保使用生产环境,以便生成资产的生产版本。

    在您可以在 Heroku 上编译资产之前,您需要能够在本地编译它们,运行以下命令来调试您的资产:

    RAILS_ENV=production bundle exec rake assets:precompile
    

    这应该没有错误地完成。如果按照 Heroku 的文档使用 Rails 3,请不要在运行此命令后将资产签入 git。

    将创建一个 public/assets 目录。在此目录中,您将找到一个 manifest.yml,其中包含 Rails 3 中已编译资产的 md5sum。在 Rails 4 中,该文件将为 manifest-.json。将 public/assets 添加到您的 git 存储库将使其可供 Heroku 使用。

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

    现在推送时,输出应显示检测到您本地编译的资产:

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

    更多帮助可以找到here

    还有here

    【讨论】:

    • 我做了上面的一切,仍然得到同样的错误
    【解决方案5】:

    在将 Rails 6 应用程序部署到 Heroku 时,我为这个问题苦苦挣扎了好几个小时。

    我在尝试部署应用程序时收到此错误:

    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_3d8b676c/bin/rake:8:in `require': cannot load such file -- rake (LoadError)
    remote:  !     from /tmp/build_3d8b676c/bin/rake:8:in `<main>'
    

    我尝试过的东西不起作用

    • 删除我的Gemfile.lock,运行bundle install,提交到远程master 分支,然后推送到heroku。
    • 运行RAILS_ENV=production bundle exec rake assets:precompile,提交到远程master 分支,然后推送到heroku。
    • Gemfile.lock 文件中删除Bundler 版本,提交到远程master 分支,然后推送到heroku。

    这是我修复的方法

    我的问题是由于我的项目的 Bundler 版本与 Heroku 的版本不同。我的Project的Bundler版本是Bundler 2.2.7,而Heroku的Bundler版本是Bundler 2.1.4。 p>

    从 Heroku 的构建日志中,我发现 Heroku 使用的 Bundler 版本是 Bundler 2.1.4

    promisepreston@my-pc:~/Projects/my-project$ git push heroku develop:master
    Enumerating objects: 193, done.
    Counting objects: 100% (193/193), done.
    Delta compression using up to 8 threads
    Compressing objects: 100% (154/154), done.
    Writing objects: 100% (155/155), 37.90 KiB | 3.45 MiB/s, done.
    Total 155 (delta 105), reused 0 (delta 0)
    remote: Compressing source files... done.
    remote: Building source:
    remote: 
    remote: -----> Building on the Heroku-20 stack
    remote: -----> Ruby app detected
    remote: -----> Installing bundler 2.1.4
    remote: -----> Removing BUNDLED WITH version in the Gemfile.lock
    remote: -----> Compiling Ruby/Rails
    remote: -----> Using Ruby version: ruby-2.7.2
    remote: -----> Installing dependencies using bundler 2.1.4
    remote:        Running: BUNDLE_WITHOUT='development:test' BUNDLE_PATH=vendor/bundle BUNDLE_BIN=vendor/bundle/bin BUNDLE_DEPLOYMENT=1 bundle install -j4
    

    接下来,我卸载了我的项目的 Bundler 2.2.7 版,剩下的默认版本是 Bundler 2.1.4 版

    这次我再次尝试部署成功了。

    就是这样。

    我希望这会有所帮助

    【讨论】:

    • 非常感谢!效果很好!如果有人想知道这是你如何回滚到旧的捆绑器版本:gem uninstall bunder 然后rm Gemfile.lock 然后gem install bundler --version '2.1.4' 然后再次捆绑,预编译资产并推送到heroku。
    • @PeterPiper - 小错字:'gem uninstall bundler'
    • 感谢修复它。除了,我不明白为什么在我以前的应用程序使用该版本部署正常时使用捆绑器 2.2.11 时它会失败。相同的平台 (DigitalOcean),几乎相同的配置,仅相差几个月。
    【解决方案6】:

    使用 rbenv 安装 ruby​​ 2.6.0

     rbenv install 2.6.0
    

    然后进入你的项目目录,设置ruby版本

     rbenv local 2.6.0
    

    删除安装包

     gem uninstall bundler
    

    然后安装最新的bundler,下面会安装最新的bundler

     gem install bundler
    

    那你就可以走了。

    【讨论】:

    • 非常感谢您的回答。像往常一样,最好的答案在页面底部:)
    【解决方案7】:

    您可能还想在您的 gem 文件中添加生产环境中的 PG Gem 文件

    宝石文件

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

    或:

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

    添加后,保存并运行以下命令:

    终端

    gem install bundler
    bundle install
    git add .
    git commit -m "Some comment here..."
    git push heroku master
    

    【讨论】:

      【解决方案8】:

      由于这篇文章反复出现在寻找我的答案,希望这对某人有所帮助:

      在将更新部署到已经启动并运行的应用程序时,我在 Heroku 上遇到了类似的错误。构建过程没有找到基本命令。这是我的错误消息的样子:

      -----> 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、rake 和启动应用程序在本地都运行良好。

      原来这是 ruby​​ buildpack 中的更新问题。我使用命令将 buildpack 版本锁定为旧版本 heroku buildpacks:set https://github.com/heroku/heroku-buildpack-ruby#v215 -a appname 并重新部署。之后一切都好。

      Heroku 堆栈 heroku-16 和 ruby​​ 版本 2.3.8

      【讨论】:

      • 天啊,它有帮助!谢谢!
      【解决方案9】:

      我遇到过这个问题,虽然我使用的是 Ruby,但我没有使用 Rails,所以运行 rake 任务的解决方案是将 rake gem 添加到 Gemfile

      # Gemfile
      
      ...
      
      gem "rake", "~> 13.0"
      

      希望这对以后的其他人有所帮助!

      【讨论】:

        【解决方案10】:

        将来可能会对某人有所帮助,尽管我认为由于我正在部署应用程序的特定性质而收到此错误。

        对我来说,

        1. 在推送之前,我没有设置生产环境所需的配置 ENV 变量。
        2. 我没有设置某些 gem 所需的构建包才能工作(Watir 等 Gem 需要)

        在 heroku 上设置 buildpack 并设置生产中所需的 ENV 变量后,我设法让它工作。

        因此,在将你的 repo 部署到 heroku 之前,请确保在 heroku 上导入所有 ENV 变量和构建包。

        【讨论】:

          【解决方案11】:

          TL;DR; 在您的 Gemfile

          的全局范围内有 gem "better_errors"gem "binding_of_caller"gem 'pry-byebug'

          就我而言,这是因为我将这 3 个 gem 从全局范围移到了 Gemfile 中的 development

          gem "better_errors"

          gem "binding_of_caller"

          gem 'pry-byebug'

          它们可能应该只在development 范围内,但是我缺少一些东西。因此,将它们移回development 范围之外,我的部署和耙子可以正常工作

          【讨论】:

            【解决方案12】:

            在我的例子中,错误是bin/rake 文件。

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

            Heroku 在顶部需要 #!/usr/bin/env ruby,如下所示:

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

            解决了! o/

            【讨论】:

              【解决方案13】:

              两个都买了

              无法检测到 rake 任务

              LoadError: 无法加载此类文件

              原来我在 require 语句上的大小写错误 - 在 Windows 上工作正常(不区分大小写的文件系统)但在 Heroku 上失败并出现这些错误(在查看“无法检测到 rake 任务”时非常误导)

              【讨论】:

                【解决方案14】:

                不幸的是,这里的答案都没有为我解决问题。我使用suspenders gem 来设置我的rails 应用程序。

                确保:

                APPLICATION_HOST=foobar RAILS_ENV=production be rake assets:precompile
                

                适用于您的设置,这样可以确保资产编译没有问题。

                调整捆绑器版本的建议修复不起作用,因为 heroku 现在默认使用固定捆绑器版本(see here)

                最终对我来说修复它的是调整我的 rake 文件并将 ruby​​ 版本设置为2.6.6。更新您的 Gemfile 和您正在使用的任何 ruby​​ 版本管理器。还要更改.ruby-version 文件以防万一。就我而言,我必须 rbenv install 2.6.6 然后我喜欢在任何地方使用相同的 ruby​​ 版本:rbenv global 2.6.6

                以前是这样的:

                require "standard/rake"# Add your own tasks in files placed in lib/tasks ending in .rake,
                # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
                
                require_relative 'config/application'
                
                Rails.application.load_tasks
                task(:default).clear
                task default: [:spec]
                
                if defined? RSpec
                  task(:spec).clear
                  RSpec::Core::RakeTask.new(:spec) do |t|
                    t.verbose = false
                  end
                end
                
                task default: "bundle:audit"
                

                然后我把它改成这样:

                # Add your own tasks in files placed in lib/tasks ending in .rake,
                # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
                
                require File.expand_path('../config/application', __FILE__)
                
                Rails.application.load_tasks
                
                if defined? RSpec
                  task(:spec).clear
                  RSpec::Core::RakeTask.new(:spec) do |t|
                    t.verbose = false
                  end
                end
                
                task default: "bundle:audit"
                

                然后它就起作用了。希望我能够为你们中的一些人节省 4 个小时来修复它。

                【讨论】:

                  【解决方案15】:

                  我在这个输出中遇到了完全相同的问题:

                  remote:        Removing bundler (1.17.3)
                  remote:        Bundle completed (29.91s)
                  remote:        Cleaning up the bundler cache.
                  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_49740f40/vendor/ruby-2.7.2/lib/ruby/2.7.0/rubygems/dependency.rb:311:in `to_specs': Could not find 'spring' (= 2.1.1) among 96 total gem(s) (Gem::MissingSpecError)
                  remote:  !     Checked in 'GEM_PATH=/tmp/build_49740f40/vendor/bundle/ruby/2.7.0', execute `gem env` for more information
                  remote:  !     from /tmp/build_49740f40/vendor/ruby-2.7.2/lib/ruby/2.7.0/rubygems/dependency.rb:323:in `to_spec'
                  remote:  !     from /tmp/build_49740f40/vendor/ruby-2.7.2/lib/ruby/2.7.0/rubygems/core_ext/kernel_gem.rb:62:in `gem'
                  remote:  !     from /tmp/build_49740f40/bin/spring:14:in `<top (required)>'
                  remote:  !     from /tmp/build_49740f40/bin/rake:7:in `load'
                  remote:  !     from /tmp/build_49740f40/bin/rake:7:in `<main>'
                  remote:  !
                  remote: /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)
                  remote: ensure you can run `$ bundle exec rake -P` against your app
                  

                  在我的情况下,问题是位于组 :development 中的 gem 'spring' 并在 Gemfile 中的生产中丢失,所以我只是退出开发并使其在所有环境中都可用。然后我运行bundle install 并推送到 git 和 Heroku,一切顺利。我刚读到这个documentation from heroku

                  【讨论】:

                    【解决方案16】:

                    对我来说,这是由 Rakefile 中的标准 gem 引起的(在尝试了其他答案中提到的所有其他修复之后)。

                    # Add your own tasks in files placed in lib/tasks ending in .rake,
                    # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
                    
                    require File.expand_path('../config/application', __FILE__)
                    # require "standard/rake"
                    
                    PatchVault::Application.load_tasks
                    
                    # task default: [:test, "standard:fix"]
                    

                    注释掉第 5 行和第 9 行后,一切正常。

                    Ruby 2.7.2,捆绑器 2.2.6

                    【讨论】:

                      【解决方案17】:

                      如果这对某人有帮助的话。 Heroku 输出告诉我自上次成功构建错误消息以来对 gemfile 的更改。我认为这极不可能修复错误,但我一时兴起决定尝试它,希望它不起作用。

                      #/Gemfile
                      # I used to have my stripe gem like this 
                      gem 'stripe', '>= 2.8', '< 6.0'
                      
                      # The format being like this caused the error
                      gem 'stripe', '< 6.0', '>= 2.8'
                      

                      嗯,我现在都看到了。软件开发女士们先生们。

                      【讨论】:

                        猜你喜欢
                        • 2021-04-14
                        • 1970-01-01
                        • 1970-01-01
                        • 1970-01-01
                        • 2018-07-09
                        • 2020-09-21
                        • 1970-01-01
                        相关资源
                        最近更新 更多