gem install pgすると失敗する。yum install postgresql-develでも解消しない。
gem install pg
すると以下のエラーが出ます。
実行しているのはEC2でOSはAmazon Linuxです。
$ gem install pg -v '0.20.0'
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
current directory: /home/ec2-user/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pg-0.20.0/ext
/home/ec2-user/.rbenv/versions/2.4.1/bin/ruby -r ./siteconf20180206-457-e5bx4w.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/ec2-user/.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/ec2-user/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/extensions/x86_64-linux/2.4.0-static/pg-0.20.0/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /home/ec2-user/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/pg-0.20.0 for inspection.
Results logged to /home/ec2-user/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/extensions/x86_64-linux/2.4.0-static/pg-0.20.0/gem_make.out
以下を実行しましたが、エラー内容は変わりませんでした。
$ sudo yum install postgresql-devel
また、psqlの設定ファイルは以下の通りです。
$ ls -l /usr/bin/pg*
lrwxrwxrwx 1 root root 35 2月 6 08:47 /usr/bin/pg_archivecleanup -> /etc/alternatives/pg_archivecleanup
lrwxrwxrwx 1 root root 45 2月 6 08:36 /usr/bin/pg_archivecleanup96 -> ../../usr/lib64/pgsql96/bin/pg_archivecleanup
lrwxrwxrwx 1 root root 31 2月 6 08:47 /usr/bin/pg_basebackup -> /etc/alternatives/pg_basebackup
lrwxrwxrwx 1 root root 41 2月 6 08:36 /usr/bin/pg_basebackup96 -> ../../usr/lib64/pgsql96/bin/pg_basebackup
lrwxrwxrwx 1 root root 27 2月 6 08:47 /usr/bin/pg_config -> /etc/alternatives/pg_config
lrwxrwxrwx 1 root root 37 2月 6 08:47 /usr/bin/pg_config92 -> ../../usr/lib64/pgsql92/bin/pg_config
lrwxrwxrwx 1 root root 37 2月 6 08:36 /usr/bin/pg_config96 -> ../../usr/lib64/pgsql96/bin/pg_config
lrwxrwxrwx 1 root root 32 2月 6 08:47 /usr/bin/pg_controldata -> /etc/alternatives/pg_controldata
lrwxrwxrwx 1 root root 42 2月 6 08:36 /usr/bin/pg_controldata96 -> ../../usr/lib64/pgsql96/bin/pg_controldata
lrwxrwxrwx 1 root root 24 2月 6 08:47 /usr/bin/pg_ctl -> /etc/alternatives/pg_ctl
lrwxrwxrwx 1 root root 34 2月 6 08:36 /usr/bin/pg_ctl96 -> ../../usr/lib64/pgsql96/bin/pg_ctl
lrwxrwxrwx 1 root root 25 2月 6 08:47 /usr/bin/pg_dump -> /etc/alternatives/pg_dump
lrwxrwxrwx 1 root root 35 2月 6 08:47 /usr/bin/pg_dump92 -> ../../usr/lib64/pgsql92/bin/pg_dump
lrwxrwxrwx 1 root root 35 2月 6 08:36 /usr/bin/pg_dump96 -> ../../usr/lib64/pgsql96/bin/pg_dump
lrwxrwxrwx 1 root root 28 2月 6 08:47 /usr/bin/pg_dumpall -> /etc/alternatives/pg_dumpall
lrwxrwxrwx 1 root root 38 2月 6 08:47 /usr/bin/pg_dumpall92 -> ../../usr/lib64/pgsql92/bin/pg_dumpall
lrwxrwxrwx 1 root root 38 2月 6 08:36 /usr/bin/pg_dumpall96 -> ../../usr/lib64/pgsql96/bin/pg_dumpall
lrwxrwxrwx 1 root root 28 2月 6 08:47 /usr/bin/pg_isready -> /etc/alternatives/pg_isready
lrwxrwxrwx 1 root root 38 2月 6 08:36 /usr/bin/pg_isready96 -> ../../usr/lib64/pgsql96/bin/pg_isready
lrwxrwxrwx 1 root root 32 2月 6 08:47 /usr/bin/pg_receivexlog -> /etc/alternatives/pg_receivexlog
lrwxrwxrwx 1 root root 42 2月 6 08:36 /usr/bin/pg_receivexlog96 -> ../../usr/lib64/pgsql96/bin/pg_receivexlog
lrwxrwxrwx 1 root root 32 2月 6 08:47 /usr/bin/pg_recvlogical -> /etc/alternatives/pg_recvlogical
lrwxrwxrwx 1 root root 42 2月 6 08:36 /usr/bin/pg_recvlogical96 -> ../../usr/lib64/pgsql96/bin/pg_recvlogical
lrwxrwxrwx 1 root root 30 2月 6 08:47 /usr/bin/pg_resetxlog -> /etc/alternatives/pg_resetxlog
lrwxrwxrwx 1 root root 40 2月 6 08:36 /usr/bin/pg_resetxlog96 -> ../../usr/lib64/pgsql96/bin/pg_resetxlog
lrwxrwxrwx 1 root root 28 2月 6 08:47 /usr/bin/pg_restore -> /etc/alternatives/pg_restore
lrwxrwxrwx 1 root root 38 2月 6 08:47 /usr/bin/pg_restore92 -> ../../usr/lib64/pgsql92/bin/pg_restore
lrwxrwxrwx 1 root root 38 2月 6 08:36 /usr/bin/pg_restore96 -> ../../usr/lib64/pgsql96/bin/pg_restore
lrwxrwxrwx 1 root root 27 2月 6 08:47 /usr/bin/pg_rewind -> /etc/alternatives/pg_rewind
lrwxrwxrwx 1 root root 37 2月 6 08:36 /usr/bin/pg_rewind96 -> ../../usr/lib64/pgsql96/bin/pg_rewind
lrwxrwxrwx 1 root root 28 2月 6 08:47 /usr/bin/pg_standby -> /etc/alternatives/pg_standby
lrwxrwxrwx 1 root root 38 2月 6 08:36 /usr/bin/pg_standby96 -> ../../usr/lib64/pgsql96/bin/pg_standby
lrwxrwxrwx 1 root root 31 2月 6 08:47 /usr/bin/pg_test_fsync -> /etc/alternatives/pg_test_fsync
lrwxrwxrwx 1 root root 41 2月 6 08:36 /usr/bin/pg_test_fsync96 -> ../../usr/lib64/pgsql96/bin/pg_test_fsync
lrwxrwxrwx 1 root root 32 2月 6 08:47 /usr/bin/pg_test_timing -> /etc/alternatives/pg_test_timing
lrwxrwxrwx 1 root root 42 2月 6 08:36 /usr/bin/pg_test_timing96 -> ../../usr/lib64/pgsql96/bin/pg_test_timing
lrwxrwxrwx 1 root root 29 2月 6 08:47 /usr/bin/pg_xlogdump -> /etc/alternatives/pg_xlogdump
lrwxrwxrwx 1 root root 39 2月 6 08:36 /usr/bin/pg_xlogdump96 -> ../../usr/lib64/pgsql96/bin/pg_xlogdump
-rwxr-xr-x 1 root root 375360 10月 14 2012 /usr/bin/pgawk
lrwxrwxrwx 1 root root 25 2月 6 08:47 /usr/bin/pgbench -> /etc/alternatives/pgbench
lrwxrwxrwx 1 root root 35 2月 6 08:36 /usr/bin/pgbench96 -> ../../usr/lib64/pgsql96/bin/pgbench
-rwxr-xr-x 2 root root 15872 3月 17 2015 /usr/bin/pgrep
libpq
を含むファイルがなかったのでこれが原因なのではないかと思い、以下を実行しましたがインストールできませんでした。
$ sudo yum install libpq-dev
読み込んだプラグイン:priorities, update-motd, upgrade-helper
amzn-main | 2.1 kB 00:00:00
amzn-updates | 2.5 kB 00:00:00
23 packages excluded due to repository priority protections
パッケージ libpq-dev は利用できません。
libpq-dev
がないためgem install pg
でエラーが起きるのでしょうか?
上記が理由の場合どのようなコマンドでインストールできるでしょうか?
gem install pg
のエラーを解決したいです。
恐れ入りますが、よろしくお願いいたします。