質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

SQLite

SQLiteはリレーショナルデータベース管理システムの1つで、サーバーではなくライブラリとして使用されている。

PostgreSQL

PostgreSQLはオープンソースのオブジェクトリレーショナルデータベース管理システムです。 Oracle Databaseで使われるPL/SQLを参考に実装されたビルトイン言語で、Windows、 Mac、Linux、UNIX、MSなどいくつものプラットフォームに対応しています。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Q&A

1回答

4624閲覧

pgのgemがインストールできないのはなぜ。

satokiyoshino

総合スコア11

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

SQLite

SQLiteはリレーショナルデータベース管理システムの1つで、サーバーではなくライブラリとして使用されている。

PostgreSQL

PostgreSQLはオープンソースのオブジェクトリレーショナルデータベース管理システムです。 Oracle Databaseで使われるPL/SQLを参考に実装されたビルトイン言語で、Windows、 Mac、Linux、UNIX、MSなどいくつものプラットフォームに対応しています。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

0グッド

0クリップ

投稿2018/04/16 08:34

編集2018/04/16 09:03

環境
ruby -v
=>ruby 2.3.3
rails -v
=>Rails 5.2.0
sql --version
=>psql (PostgreSQL) 10.3

この状態で、新しく
rails new hoge -d postgresql
でアプリを作成すると、

An error occurred while installing pg (1.0.0), and Bundler cannot continue. Make sure that `gem install pg -v '1.0.0'` succeeds before bundling.

このようなエラーが出てしまいます。
このエラー通りに

sudo gem install pg -v '1.0.0'

をしたところ、

hoge:desktop hoge$ sudo gem install pg -v '1.0.0' Building native extensions. This could take a while... ERROR: Error installing pg: ERROR: Failed to build gem native extension. current directory: /Library/Ruby/Gems/2.3.0/gems/pg-1.0.0/ext /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20180416-8796-1v2mml5.rb extconf.rb checking for pg_config... yes Using config values from /usr/local/bin/pg_config checking for libpq-fe.h... yes checking for libpq/libpq-fs.h... yes checking for pg_config_manual.h... yes checking for PQconnectdb() in -lpq... no checking for PQconnectdb() in -llibpq... no checking for PQconnectdb() in -lms/libpq... no Can't find the PostgreSQL client library (libpq) *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options. Provided configuration options: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/$(RUBY_BASE_NAME) --with-pg --without-pg --enable-windows-cross --disable-windows-cross --with-pg-config --without-pg-config --with-pg_config --without-pg_config --with-pg-dir --without-pg-dir --with-pg-include --without-pg-include=${pg-dir}/include --with-pg-lib --without-pg-lib=${pg-dir}/lib --with-pqlib --without-pqlib --with-libpqlib --without-libpqlib --with-ms/libpqlib --without-ms/libpqlib To see why this extension failed to compile, please check the mkmf.log which can be found here: /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-17/2.3.0/pg-1.0.0/mkmf.log extconf failed, exit code 1 Gem files will remain installed in /Library/Ruby/Gems/2.3.0/gems/pg-1.0.0 for inspection. Results logged to /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-17/2.3.0/pg-1.0.0/gem_make.out

となり、エラーが出てしまいます。
これを治すにはどのようにすればよいでしょうか。

P.S /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-17/2.3.0/pg-1.0.0/gem_make.outの中身は下記です。

current directory: /Library/Ruby/Gems/2.3.0/gems/pg-1.0.0/ext /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20180416-8796-1v2mml5.rb extconf.rb checking for pg_config... yes Using config values from /usr/local/bin/pg_config checking for libpq-fe.h... yes checking for libpq/libpq-fs.h... yes checking for pg_config_manual.h... yes checking for PQconnectdb() in -lpq... no checking for PQconnectdb() in -llibpq... no checking for PQconnectdb() in -lms/libpq... no Can't find the PostgreSQL client library (libpq) *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options. Provided configuration options: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/$(RUBY_BASE_NAME) --with-pg --without-pg --enable-windows-cross --disable-windows-cross --with-pg-config --without-pg-config --with-pg_config --without-pg_config --with-pg-dir --without-pg-dir --with-pg-include --without-pg-include=${pg-dir}/include --with-pg-lib --without-pg-lib=${pg-dir}/lib --with-pqlib --without-pqlib --with-libpqlib --without-libpqlib --with-ms/libpqlib --without-ms/libpqlib To see why this extension failed to compile, please check the mkmf.log which can be found here: /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-17/2.3.0/pg-1.0.0/mkmf.log extconf failed, exit code 1

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

kazto

2018/04/16 08:36

`/Library/Ruby/Gems/2.3.0/extensions/universal-darwin-17/2.3.0/pg-1.0.0/gem_make.out` の中にエラーの詳細が書かれていますので、貼り付けてください。
satokiyoshino

2018/04/16 09:04

記載しました!よろしくお願いいたします。
guest

回答1

0

つbrew install libpq

投稿2018/04/16 09:03

hichon

総合スコア5737

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

satokiyoshino

2018/04/16 09:18

brew install libpq 自体はうまくいったのですが、そこから先は変わらずです。。
hichon

2018/04/16 20:29

以下のエラーが別の内容になっているはずなので、順番に潰していくしか無いです。 > Can't find the PostgreSQL client library (libpq)
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問