問題
Can't find the 'libpq-fe.h header
ヘッダーがないためposgresqlのライブラリ(NativeExtension)がコンパイルできずに、失敗した。
$ Gemfile
gem 'pg'
コマンド
$ ./bin/bundle install --path vendor/bundle
出力結果
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/Users/saicologic/.rbenv/versions/2.1.6/bin/ruby extconf.rb
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
--with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** 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=/Users/saicologic/.rbenv/versions/2.1.6/bin/ruby
--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
extconf failed, exit code 1
解決
Install posgresql
$ brew install postgresql
出力結果
==> Downloading https://homebrew.bintray.com/bottles/postgresql-9.4.1_1.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring postgresql-9.4.1_1.yosemite.bottle.tar.gz
==> Caveats
If builds of PostgreSQL 9 are failing and you have version 8.x installed,
you may need to remove the previous version first. See:
https://github.com/Homebrew/homebrew/issues/2510
To migrate existing data from a previous major version (pre-9.4) of PostgreSQL, see:
https://www.postgresql.org/docs/9.4/static/upgrading.html
To have launchd start postgresql at login:
ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
Then to load postgresql now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
Or, if you don't want/need launchctl, you can just run:
postgres -D /usr/local/var/postgres
==> /usr/local/Cellar/postgresql/9.4.1_1/bin/initdb /usr/local/var/postgres
==> Summary