RailsからHerokuにデプロイしようとしたらerror: failed to push some refs to 'https://git.heroku.com/xxx.git'というエラーが出た
開発環境
macOS Catalina
Rails 6.1.3.2
Ruby 2.6.7
Herokuにデプロイしようとするとエラーが出る
RailsからHerokuにデプロイした際に以下のようなエラーが...
error: failed to push some refs to 'https://git.heroku.com/xxx.git'
プッシュに失敗しましたと出ています。
解決方法
ブラウザからHerokuにログインし、作成したアプリケーション画面のOverviewタブの
右側にある「Latest activity」の「Build failed」となっているアクティビティの「 View build log」をクリック。
するとこのような記載がありました。
-----> Building on the Heroku-20 stack
-----> Determining which buildpack to use for this app
! Warning: Multiple default buildpacks reported the ability to handle this app. The first buildpack in the list below will be used.
Detected buildpacks: Ruby,Node.js
See https://devcenter.heroku.com/articles/buildpacks#buildpack-detect-order
-----> Ruby app detected
-----> Installing bundler 2.2.16
-----> Removing BUNDLED WITH version in the Gemfile.lock
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.6.7
-----> Installing dependencies using bundler 2.2.16
Running: BUNDLE_WITHOUT='development:test' BUNDLE_PATH=vendor/bundle BUNDLE_BIN=vendor/bundle/bin BUNDLE_DEPLOYMENT=1 bundle install -j4
Your bundle only supports platforms ["x86_64-darwin-19"] but your local platform
is x86_64-linux. Add the current platform to the lockfile with `bundle lock
--add-platform x86_64-linux` and try again.
Bundler Output: Your bundle only supports platforms ["x86_64-darwin-19"] but your local platform
is x86_64-linux. Add the current platform to the lockfile with `bundle lock
--add-platform x86_64-linux` and try again.
!
! Failed to install gems via Bundler.
!
! Push rejected, failed to compile Ruby app.
! Push failed
エラー文を日本語訳して抜粋すると
バンドルはプラットフォーム["x86_64-darwin-19"]しかサポートしていませんが、あなたのローカルプラットフォームはx86_64-linux です。
現在のプラットフォームをロックファイルに追加するには、bundle lock--add-platform x86_64-linux
でロックファイルに現在のプラットフォームを追加して、もう一度試してみてください。
となっており、その通りに実行。
% bundle lock--add-platform x86_64-linux
そして変更を忘れずにコミットする。
% git add .
% git commit -m 'Add platform'
再度Herokuにデプロイ。
% git push heroku master
無事にデプロイできましたー!!!
Author And Source
この問題について(RailsからHerokuにデプロイしようとしたらerror: failed to push some refs to 'https://git.heroku.com/xxx.git'というエラーが出た), 我々は、より多くの情報をここで見つけました https://qiita.com/CoGee/items/2f509402dec47c820d32著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .