gem install pgでエラー(libpq-fe.h... no)
07 Sep 2017postgresql用のgemのインストールでエラー
$ gem install pg
Fetching: pg-0.21.0.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
current directory: /home/vagrant/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pg-0.21.0/ext
/home/vagrant/.rbenv/versions/2.4.1/bin/ruby -r ./siteconf20170906-6891-137sln2.rb extconf.rb
checking for pg_config... yes
Using config values from /usr/bin/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=/home/vagrant/.rbenv/versions/2.4.1/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
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/home/vagrant/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/extensions/x86_64-linux/2.4.0-static/pg-0.21.0/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /home/vagrant/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pg-0.21.0 for inspection.
Results logged to /home/vagrant/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/extensions/x86_64-linux/2.4.0-static/pg-0.21.0/gem_make.out
postgresql-develをインストールして解決。
$ sudo yum install postgresql-devel
Loaded plugins: fastestmirror
base | 3.6 kB 00:00:00
extras | 3.4 kB 00:00:00
updates | 3.4 kB 00:00:00
Loading mirror speeds from cached hostfile
* base: www.ftp.ne.jp
* extras: www.ftp.ne.jp
* updates: www.ftp.ne.jp
Resolving Dependencies
--> Running transaction check
---> Package postgresql-devel.x86_64 0:9.2.18-1.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==========================================================================================================================================
Package Arch Version Repository Size
==========================================================================================================================================
Installing:
postgresql-devel x86_64 9.2.18-1.el7 base 950 k
Transaction Summary
==========================================================================================================================================
Install 1 Package
Total download size: 950 k
Installed size: 3.9 M
Is this ok [y/d/N]: y
Downloading packages:
postgresql-devel-9.2.18-1.el7.x86_64.rpm | 950 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : postgresql-devel-9.2.18-1.el7.x86_64 1/1
Verifying : postgresql-devel-9.2.18-1.el7.x86_64 1/1
Installed:
postgresql-devel.x86_64 0:9.2.18-1.el7
Complete!
改めてインストール
[vagrant@localhost ruby]$ gem install pg
Building native extensions. This could take a while...
Successfully installed pg-0.21.0
Parsing documentation for pg-0.21.0
Installing ri documentation for pg-0.21.0
Done installing documentation for pg after 0 seconds
1 gem installed