M1 MacでRailsのプログラムをHerokuにpushしようとしたらYour bundle only supports platforms [“arm64-darwin-20”] but your local platformというエラーが出たので対処法を紹介します。
目次
エラー内容
エラー内容は以下の通り、プラットフォームの互換性の問題のようです。M1 Mac特有ですね。
remote: Building source: remote: remote: -----> Building on the Heroku-20 stack remote: -----> Determining which buildpack to use for this app remote: ! Warning: Multiple default buildpacks reported the ability to handle this app. The first buildpack in the list below will be used. remote: Detected buildpacks: Ruby,Node.js remote: See https://devcenter.heroku.com/articles/buildpacks#buildpack-detect-order remote: -----> Ruby app detected remote: -----> Installing bundler 2.2.33 remote: -----> Removing BUNDLED WITH version in the Gemfile.lock remote: -----> Compiling Ruby/Rails remote: -----> Using Ruby version: ruby-3.0.0 remote: -----> Installing dependencies using bundler 2.2.33 remote: Running: BUNDLE_WITHOUT='development:test' BUNDLE_PATH=vendor/bundle BUNDLE_BIN=vendor/bundle/bin BUNDLE_DEPLOYMENT=1 bundle install -j4 remote: Your bundle only supports platforms ["arm64-darwin-20"] but your local platform remote: is x86_64-linux. Add the current platform to the lockfile with bundle lock remote: --add-platform x86_64-linux and try again. remote: Bundler Output: Your bundle only supports platforms ["arm64-darwin-20"] but your local platform remote: is x86_64-linux. Add the current platform to the lockfile with bundle lock remote: --add-platform x86_64-linux and try again. remote: remote: ! remote: ! Failed to install gems via Bundler. remote: ! remote: ! Push rejected, failed to compile Ruby app. remote: remote: ! Push failed
対処法
エラーの文面にも書かれていますが、下記コマンドを実行してHerokuの実行環境を追加すると上手くpushできるようになります。
bundle lock --add-platform x86_64-linux
Gemfile.clockのplatformには、M1の実行環境に加えてHerokuの実行環境も追加されていることが分かります。
PLATFORMS arm64-darwin-20 x86_64-linux
pushの前にcommitも忘れずに。
git add . git commit -m 'Add platform'
Herokuにpushします。
git push heroku master
コメント