无法检测rake任务

Dmi*_*try 12 heroku

   ensure you can run `$ bundle exec rake -P` against your app with no environment variables present
   and using the production group of your Gemfile.
   This may be intentional, if you expected rake tasks to be run
   cancel the build (CTRL+C) and fix the error then commit the fix:
   rake aborted!
Run Code Online (Sandbox Code Playgroud)

我没有任何我想自动运行的rake任务.我应该忽略这个警告吗?

use*_*833 5

自 2013 年 12 月 5 日起,Heroku 添加了使用 Ruby 构建包进行部署的调试输出

错误被触发:

  • 如果assets:precompile任务不存在或者
  • 如果 Rakefile 中有错误。
    • Rakefile 中错误的两个常见原因是引用生产中不可用的依赖项(例如 rspec)或
    • 期望存在环境变量。

这是违反直觉的,因为应用程序永远不会在没有配置变量的情况下运行,但Heroku 的构建过程在没有配置变量的情况下执行。

根据错误消息,确保在推送到 Heroku 之前可以bundle exec rake -P RAILS_ENV=production 在没有环境变量的情况下运行(例如,在运行上述命令时注释掉环境变量)。

另外,请放心,该rake开关-P是无害的,因此您可以随意运行它,直到解决此问题。此开关用于显示所有任务及其直接先决条件的列表。如果您想仔细检查,请参阅Rake 命令行用法。输出可能有多200行,看起来像这样:

rake about
    environment
rake assets:clean
    environment
rake assets:clobber
    environment
rake assets:environment
rake assets:precompile
    environment
rake db:_dump
...
rake tmp:pids:clear
rake tmp:sessions:clear
rake tmp:sockets:clear
Run Code Online (Sandbox Code Playgroud)

  • 对于 Rails 应用程序来说可能是这样,但其他 Rack 应用程序不一定如此,例如 Middleman。就我而言,将“rake”添加到“Gemfile”中_确实_有意义。 (4认同)
  • 另外,请确保您的 Gemfile 包含“rake”。对我来说就这么简单。不过,仍然不明白为什么现在在 Gemfile 中需要它,而以前不需要。 (2认同)

dwa*_*mac 1

您还可以尝试启用 user-env-compile

heroku labs:enable user-env-compile
Run Code Online (Sandbox Code Playgroud)

  • “找不到该功能。” (8认同)
  • 如果能详细说明它的作用以及它为什么会起作用,那就太好了。 (3认同)