【问题标题】:Why I get an Error when trying deploy Ruby on Rails app to Heroku?为什么在尝试将 Ruby on Rails 应用程序部署到 Heroku 时出现错误?
【发布时间】:2019-11-11 04:20:20
【问题描述】:

当我尝试将我的 Ruby on Rails 应用程序部署到 Heroku 时,我遇到了一些错误:

git push heroku master
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 585 bytes | 585.00 KiB/s, done.
Total 5 (delta 3), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Rake app detected
remote: rake aborted!
remote: LoadError: cannot load such file -- bundler/setup
remote: /tmp/build_7852350a661d0da59c96dfb8f01c0e07/config/boot.rb:3:in `<top (required)>'
remote: /tmp/build_7852350a661d0da59c96dfb8f01c0e07/config/application.rb:1:in `require_relative'
remote: /tmp/build_7852350a661d0da59c96dfb8f01c0e07/config/application.rb:1:in `<top (required)>'
remote: /tmp/build_7852350a661d0da59c96dfb8f01c0e07/Rakefile:4:in `require_relative'
remote: /tmp/build_7852350a661d0da59c96dfb8f01c0e07/Rakefile:4:in `<top (required)>'
remote: (See full trace by running task with --trace)
remote:  !     Push rejected, failed to compile Rake app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
remote: !   Push rejected to remojobs.
remote: 
To https://git.heroku.com/sampleapp-miro.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/sampleapp-miro.git'

我使用 Ruby 2.4.0、Rails 5.2.3,而 Bundler 是 2.0.2。

下面是来自heroku logs 的完整错误:

2019-06-29T18:04:32.000000+00:00 app[api]: Build started by user info@myemail.com
2019-06-29T18:04:34.000000+00:00 app[api]: Build failed -- check your build output: https://dashboard.heroku.com/apps/8a339527-87e4-40c9-bee5-326119c29f60/activity/builds/a430cb9b-857a-4764-9abc-cefd14e45caf
2019-06-29T18:08:37.167236+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=sampleapp-miro.herokuapp.com request_id=f2ff0cfa-9faa-46d8-81c2-cd8c200fdc8a fwd="195.136.56.0" dyno= connect= service= status=503 bytes= protocol=https
2019-06-29T18:08:41.059684+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=sampleapp-miro.herokuapp.com request_id=456e9d84-7286-4b75-8a7d-50e397b9b8be fwd="195.136.56.0" dyno= connect= service= status=503 bytes= protocol=https
2019-06-29T18:09:09.000000+00:00 app[api]: Build started by user info@myemail.com
2019-06-29T18:09:10.000000+00:00 app[api]: Build failed -- check your build output: https://dashboard.heroku.com/apps/8a339527-87e4-40c9-bee5-326119c29f60/activity/builds/c596ea0f-4936-45e1-a415-517178338c70
2019-06-29T18:13:26.000000+00:00 app[api]: Build started by user info@myemail.com
2019-06-29T18:13:27.000000+00:00 app[api]: Build failed -- check your build output: https://dashboard.heroku.com/apps/8a339527-87e4-40c9-bee5-326119c29f60/activity/builds/c78a0330-354f-4c1f-b04e-24418ab36b02
2019-06-29T18:14:42.000000+00:00 app[api]: Build started by user info@myemail.com
2019-06-29T18:14:43.000000+00:00 app[api]: Build failed -- check your build output: https://dashboard.heroku.com/apps/8a339527-87e4-40c9-bee5-326119c29f60/activity/builds/29cfa1cd-6af1-4bcc-8b4d-825e9131043c
2019-06-29T18:15:32.000000+00:00 app[api]: Build started by user info@myemail.com
2019-06-29T18:15:33.000000+00:00 app[api]: Build failed -- check your build output: https://dashboard.heroku.com/apps/8a339527-87e4-40c9-bee5-326119c29f60/activity/builds/43c3e880-6880-4cc8-b8b1-5184e7d66c86
2019-06-29T18:17:04.000000+00:00 app[api]: Build started by user info@myemail.com
2019-06-29T18:17:05.000000+00:00 app[api]: Build failed -- check your build output: https://dashboard.heroku.com/apps/8a339527-87e4-40c9-bee5-326119c29f60/activity/builds/d10a1410-48e9-48d1-9400-43a1b4fa0ea1

当我运行heroku buildpacks 时,我看到了

Buildpack URL https://github.com/gunpowderlabs/buildpack-ruby-rake-deploy-tasks

更新

我用过: heroku buildpacks:remove https://github.com/gunpowderlabs/buildpack-ruby-rake-deploy-tasks

之后:

git push heroku master

给我以下错误:

remote: Bundle completed (163.52s) remote: Cleaning up the bundler cache. remote: -----> Installing node-v10.15.3-linux-x64 remote: -----> Detecting rake tasks 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) - did find: [bundler-2.0.2] remote: ! Checked in 'GEM_PATH=vendor/bundle/ruby/2.4.0', execute 'gem env' for more information remote: ! To install the version of bundler this project requires, run gem install bundler -v '2.0.1' remote: /app/tmp/buildpacks/b7af56db6e6816adee09d510091abc07/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 remote: and using the production group of your Gemfile. remote: Activating bundler (2.0.1) failed: remote: Could not find 'bundler' (= 2.0.1) - did find: [bundler-2.0.2] remote: Checked in 'GEM_PATH=vendor/bundle/ruby/2.4.0', execute 'gem env' for more information remote: To install the version of bundler this project requires, run gem install bundler -v '2.0.1'

【问题讨论】:

  • 您的 GemfileGemfile.lock 是否是最新的并包含在您的存储库中?
  • @Chris 是的,GemfileGemfile.lock 正常包括在内。
  • edit您的问题,并在您已经分享的内容之前添加日志输出。
  • 我刚刚编辑了帖子并添加了 Heroku 日志。
  • 好的,所以您的日志显示No web processes running。 (a) 你的Procfile 中有什么内容? (b) 您的 GemfileGemfile.lock 是否已检入您的存储库?

标签: ruby-on-rails ruby git heroku bundler


【解决方案1】:

好的,我解决了这个问题。也许将来会对某人有所帮助:

  • 将 Ruby 版本更新到 2.6.1
  • gem uninstall bundler 并再次安装 gem install bundler -v 2.0.2
  • 删除 Gemfile.lock 和 bundle install
  • git push heroku master
  • 有效 :)

【讨论】:

    【解决方案2】:

    嗯,heroku buildpacks 只显示

    Buildpack URL https://github.com/gunpowderlabs/buildpack-ruby-rake-deploy-tasks
    

    你的问题。在某些时候,您明确选择了这个 buildpack,但它是错误的。我建议removing the buildpack setting

    heroku buildpacks:remove https://github.com/gunpowderlabs/buildpack-ruby-rake-deploy-tasks
    

    然后再次运行heroku buildpacks。您应该会看到类似

    <your-app> has no Buildpack URL set.
    

    完成后,redeploy 您的代码。 Heroku 将通过 Gemfile 的存在来识别 Ruby 项目并自动使用适当的 buildpack。

    【讨论】:

    • 好的,我已经完成了您的上述建议。一切都很好,直到捆绑完成:remote: ! Could not detect rake tasksremote: ! ensure you can run '$ bundle exec rake -P' against your appremote: ! and using the production group of your Gemfile.remote: ! Activating bundler (2.0.1) failed:remote: ! Could not find 'bundler' (= 2.0.1) - did find: [bundler-2.0.2]remote: ! Checked in 'GEM_PATH=vendor/bundle/ruby/2.4.0', execute 'gem env'remote: ! To install the version of bundler this project requires, run 'gem install bundler -v '2.0.1''
    • 这在评论中很难读懂。请编辑您的问题并在此处添加更新的信息。
    • 我现在又看到了一件事:当我卸载所有捆绑程序版本(2.0.1 和 2.0.2)并再次安装 2.0.1 时,出现以下错误 - 我在尝试时看到 Installing dependencies using bundler 2.0.2再次发送至git push heroku master。你知道为什么吗?
    • 并且在 Gemfile.lock 的底部是:RUBY VERSION: ruby 2.4.0p0BUNDLED WITH: 2.0.1
    • 好的,我解决了上面的问题,我添加了更新的信息。谢谢:)
    猜你喜欢
    • 1970-01-01
    • 2016-12-25
    • 1970-01-01
    • 2016-04-10
    • 1970-01-01
    • 2015-10-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多