LoginSignup
1
0

More than 3 years have passed since last update.

Rails herokuのエラー:Failed to install gems via Bundler. の対応

Posted at

ポートフォリオ作成の際に、詰まったのでメモ
bundle installしても解決しない場合です。

環境

ruby 2.6.6
Rails 6.0.3

経緯

$ heroku create

後に

$ git push heroku main

そこでエラー発生

.
.
remote:  !
remote:  !     Failed to install gems via Bundler.
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.
remote:
remote:  !     Push failed
.
.

解決方法

エラー文を読むと、bundlerに問題あるとのこと
heroku公式サイトからbundlerの記事を検索してみる。

Applications specifying Bundler 2.x in their
Gemfile.lock will receive bundler: 2.2.15
Applications specifying Bundler 1.x in their
Gemfile.lock will receive bundler: 1.17.3
Applications with no BUNDLED WITH in their
Gemfile.lock will default to bundler: 1.17.3

https://devcenter.heroku.com/articles/ruby-support#supported-runtimes
2021年 4月現在

今のbundlerのversionはいくつかな?

$ bundler -v
Bundler version 2.x.xx

ふむ、この場合

Applications specifying Bundler 2.x in their
Gemfile.lock will receive bundler: 2.2.15

とあるので、2.2.15にしないといけないらしい。

bundlerのversionを設定し直す

まずアンインストール

$ gem uninstall bundler

version指定して再インストール

$ gem install bundler --version '2.2.15'

gemfile.lockを消去
(あとでbundle installして最新のものを作成)

$ rm gemfile.lock

version 2.2.15で、bundle install

$ bundle _2.2.15_ install

git add, commit して再デプロイ

$ git push heroku

通りました。

これでも、解消しない場合、エラー文をよく読むと

.
.
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

で解決することもあるそうです。

ついで

$ heroku create NAME

NAME 部分に好き文字を付けることができますが、付けない場合はランダムになります。
もし後からつけたい場合、

$ heroku app:rename NAME

で簡単に書き換えられます。

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