新しいアプリを作っていて、Herokuにpushすると、buildに失敗した。
こんなエラー文を吐いた。
-----> Building on the Heroku-20 stack -----> Determining which buildpack to use for this app -----> Ruby app detected -----> Installing bundler 2.3.10 -----> Removing BUNDLED WITH version in the Gemfile.lock -----> Compiling Ruby/Rails -----> Using Ruby version: ruby-3.0.2 -----> Installing dependencies using bundler 2.3.10 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
解決するために素直にコマンドを打つ。
>bundle lock --add-platform x86_64-linux
Gemfile.lockが更新される。こんな差分。linuxが追加されている。
... nokogiri (1.13.8-x86_64-darwin) racc (~> 1.4) + nokogiri (1.13.8-x86_64-linux) + racc (~> 1.4) pg (1.4.3) pry (0.14.1) coderay (~> 1.1) ... PLATFORMS x86_64-darwin-19 + x86_64-linux DEPENDENCIES better_errors ...
bundler 2.2以降では、bundle installがされたOSがPLATFORMSに加えれられるらしい。 HEROKUはLinuxで動いているので、Linuxをプラットフォームに追加してくれ、というエラーだったらしい。
参考
Understanding The Gemfile.lock File
(了)