LoginSignup
0
1

More than 1 year has passed since last update.

RailsからHerokuにデプロイしようとしたらerror: failed to push some refs to 'https://git.heroku.com/xxx.git'というエラーが出た

Last updated at Posted at 2021-06-06

開発環境

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タブの
スクリーンショット 2021-06-06 15.10.06.png

右側にある「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 

無事にデプロイできましたー!!!

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1