LoginSignup
1
0

More than 1 year has passed since last update.

herokuにpushしようと思ったらFailed to install gems via Bundle.と怒られる

Posted at

結論

  • herokuとローカル環境でのbundlerのversionを合わせる
  • bundle lock --add-platform x86_64-linuxを実行する

やったこと

まずはエラー文を読み、

remote:        Your bundle only supports platforms ["x86_64-darwin-19"] 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.

とあったので、 bundle lock --add-platform x86_64-linuxを実行するが、エラーが出た。

Failed to install gems via Bundle.でググると、「herokuとローカル環境でのbundlerのversionがあっていないことが原因だった」という記事を見つけたので、herokuのbundlerのバージョンと、ローカルのバージョンを確認する。

herokuで使っているバージョンは

$ git push heroku

を実行したときに表示されていた

remote: -----> Ruby app detected
remote: -----> Installing bundler 2.2.16
remote: -----> Removing BUNDLED WITH version in the Gemfile.lock
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-3.0.1

 のInstalling bundler 2.2.16らしい。
ローカルでのバージョン確認は

$ bundler -v
Bundler version 2.2.17

herokuは2.2.16、ローカルは2.2.17でバージョンが違うかった。

いったんGemfile.lockを削除

$ rm gemfile.lock

次にherokuとバージョンを合わせたbundlerをインストール

$ bundle _2.2.16_ install --without production

それから

$ bundle lock --add-platform x86_64-linux

$ git add .
$ git commit -m 'bundlerのバージョン変更'
$ git push heroku

いけました。

まとめ

最近エラーが出ても耐性がついてきた。特にRailsは日本語の記事がたくさんあり、だいたいエラー文で調べれば出てくることが多いような気がします。

1
0
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
1
0