4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Gemfileインストール時のエラー(An error occurred while installing pg (0.20.0), and Bundler cannot continue.)

Last updated at Posted at 2019-12-06

Railsチュートリアル3.1のbundle installで発生したエラーへの初心者なりの対処法です。

  • 発生したエラーと対処
  • 後書き

の順に書いていきます。

発生したエラーと対処

Railsチュートリアル3.1の手順に沿ってGemfileを上書き後"bundle install --without production"したところ、エラーになり"bundle update"するようにとのメッセージが出ました。
言われた通りにupdateすると次のようなエラーが出ました。

qiita.rb
An error occurred while installing pg (0.20.0), and Bundler cannot continue.
Make sure that `gem install pg -v '0.20.0' --source 'https://rubygems.org/'` succeeds
before bundling.

ソースを確認しろと言われてもRubyGemsのページに行ったところで何もできず、検索してもそれらしい解決法を見つけられず、とりあえずもう一度インストール

qiita.rb
You have requested:
  spring = 2.0.2

The bundle currently has spring locked at 2.1.0.
Try running `bundle update spring`

If you are updating multiple gems in your Gemfile at once,
try passing them all to `bundle update`

エラーメッセージが変わっていたので次は"bundle update spring"を実行

qiita.rb
You have requested:
  minitest = 5.10.3

The bundle currently has minitest locked at 5.13.0.
Try running `bundle update minitest`

If you are updating multiple gems in your Gemfile at once,
try passing them all to `bundle update`

さらにメッセージが変わったので次は"bundle update minitest"を実行

qiita.rb
You have requested:
  spring = 2.0.2

The bundle currently has spring locked at 2.1.0.
Try running `bundle update spring`

If you are updating multiple gems in your Gemfile at once,
try passing them all to `bundle update`

またエラーメッセージですがそれはさっきしたよってことで"bundle update --without production"をしてみると無事インストールに成功しました。

後書き

まだ学び始めで技術的なことは何も言えないのですが初心者は取り敢えずエラーメッセージと向き合うことから始めるべきだなという気づきがあったため投稿しておきました。
自分はエラーが出てとりあえずGoogleで検索をしたのですが、”brewを試す””検索パスは通っているか?”のようなよく分からないものばかりで混乱してしまいました。
下手にイジっても復旧させる技術がないので躊躇し、もう一度エラーメッセージを読み直してみようと思った結果、無事に解決した次第です。

初心者の落ち入るエラーなんて大したものじゃないことがほとんどだと思います。
英語とエラーから逃げずに頑張ろう!!

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?