LoginSignup
0

More than 5 years have passed since last update.

mac / gem install pg_typecast でエラー

Posted at

ActiveRecordでRedShiftにアクセスしたいから、以下の2つのgemをインストールしました。

  • activerecord4-redshift-adapter
  • pg_typecast

activerecord4-redshift-adapterはさっくり入りましたら、pg_typecastで苦戦。

インストールしようとしたら、以下のエラーが。。。

$ gem install pg_typecast

uilding native extensions.  This could take a while...
ERROR:  Error installing pg_typecast:
    ERROR: Failed to build gem native extension.

    /usr/local/opt/ruby/bin/ruby -r ./siteconf20151013-2900-1269pij.rb extconf.rb
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
compiling pg_typecast.c
pg_typecast.c:5:10: fatal error: 'libpq-fe.h' file not found
#include <libpq-fe.h>
         ^
1 error generated.
make: *** [pg_typecast.o] Error 1

make failed, exit code 2

結局のところ、libpq-fe.hのパスが通らないってことで、findしてみたらいるんですよね。

$ sudo find / -name 'libpq-fe.h'
/Library/PostgreSQL/9.3/include/libpq-fe.h

ググってもわからず、結局、pg_typecastのソースを見るハメに。。。
https://github.com/deepfryed/pg_typecast/blob/master/ext/extconf.rb

extconf.rbの先頭の方で、PATHを設定している。

incdir = `pg_config --includedir`.chomp rescue ENV.fetch('POSTGRES_INCLUDE', '/usr/include/postgresql')
libdir = `pg_config --libdir`.chomp     rescue ENV.fetch('POSTGRES_LIB',     '/usr/lib')

pgのgemのときもだったけど、結局、pg_configが$PATHのところにいないのが原因。
/usr/local/binにリンク貼って解決!

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
0