【Cloud9】An error occurred while installing pg (0.20.0), and Bundler cannot continue.でbundel install中にエラー【Rails】

rails-logo

 

こんにちは。たなかです。

引き続きRails Tutorial進めています。

先日、学習中に以下のようなエラーに遭遇したので対処法を備忘録としてシェアします。

症状

bundle install時に以下のエラーが表示されました

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.

pgerror

わざわざ赤文字で警告してくれています。

 

「pgインストール中にエラー起きちゃいましたよ!」
「bundleする前に’gem install pg -v ‘0.20.0’が成功するか確認してね!」

 

と仰っているようです。

なるほどわかりましたと、上記コマンドを実行 => 成功。

もう一度bundle install……

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.

状況が変わらん!!!!!!何をさせたかったんじゃ!!!!!

解決方法

pgのインストールに必要なライブラリを先に入れる

ということで以下のコマンドを実行

$ sudo yum install postgresql-devel

ビャーッとログが走って

 
  Dependencies Resolved

==========================================================================================================================
 Package                          Arch                 Version                           Repository                  Size
==========================================================================================================================
Installing:
 postgresql92-devel               x86_64               9.2.24-2.66.amzn1                 amzn-updates               1.1 M
Installing for dependencies:
 postgresql92                     x86_64               9.2.24-2.66.amzn1                 amzn-updates               4.1 M
 postgresql92-libs                x86_64               9.2.24-2.66.amzn1                 amzn-updates               261 k

Transaction Summary
==========================================================================================================================
Install  1 Package (+2 Dependent packages)

Total download size: 5.4 M
Installed size: 20 M
Is this ok [y/d/N]:y

Is this ok のところでyを入力。

 
Installed:
  postgresql92-devel.x86_64 0:9.2.24-2.66.amzn1                                                                           

Dependency Installed:
  postgresql92.x86_64 0:9.2.24-2.66.amzn1                   postgresql92-libs.x86_64 0:9.2.24-2.66.amzn1                  

Complete!

うまくいったみたい。

これでpgのインストール準備が完了です。

 

再度bundle installを実行……

Bundle complete! 22 Gemfile dependencies, 81 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.

無事に通りました!いえす!

まとめ

rails-logo

段階を踏もう

 

ということでpgが邪魔してbundle install通らない問題の解消法についてでした。

railsチュートリアルに限らず、エラーメッセーをよく読んでもうまく行かないことは多々あるので、エラー内容でググって対応手段を増やし、順々にやってみましょう。

同じエラーで苦心している方の助力になったら幸いです。

今回はここまで。

参考サイト

  • https://www.t4traw.net/blog/2018/03/awsamazon-cloud9%E3%81%A7postgresql%E3%82%92%E8%B5%B7%E5%8B%95%E3%81%97%E3%82%88%E3%81%86%E3%81%A8%E3%81%97%E3%81%9F%E3%82%89postgresql-unrecognized-service%E3%81%A8%E8%A1%A8%E7%A4%BA%E3%81%95%E3%82%8C%E3%82%8B%E5%95%8F%E9%A1%8C%E3%81%AE%E8%A7%A3%E6%B1%BA%E6%96%B9%E6%B3%95/

コメントを残す

メールアドレスが公開されることはありません。