86
46

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.

`gem install pg` が失敗するときの対処法

Posted at

pg をインストールしようとすると次のような結果となる

$ gem install pg -v '0.18.4'
	Fetching: pg-0.18.4.gem (100%)
	Building native extensions.  This could take a while...
	ERROR:  Error installing pg:
		ERROR: Failed to build gem native extension.
...

ログを眺めてみるとこんな内容が書かれている

.log
clang -E -I/usr/local/Cellar/ruby/2.3.1/include/ruby-2.3.0/x86_64-darwin15 -I/usr/local/Cellar/ruby/2.3.1/include/ruby-2.3.0/ruby/
conftest.c:3:10: fatal error: 'libpq-fe.h' file not found
#include <libpq-fe.h>
         ^
1 error generated.

libpq-fe.h が見当たらないらしい。
次のコマンドで postgresql をインストールすることで解決。

brew install postgresql

ちなみに、yumとかapt-getとか使ってる場合は次のコマンドを使えばいいらしい
(動作未確認...)

yum install postgresql-devel
apt-get install libpq-dev
86
46
3

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
86
46

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?