安装pg gem时出错。 OS X 10.10.2

时间:2015-12-16 08:28:01

标签: ruby-on-rails ruby pg

我在安装pg gem时遇到问题。但捆绑是成功的。 也许smith with"无法找到PostgreSQL客户端库(libpq)"

$ sudo gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config
Building native extensions with: '--with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config'
This could take a while...
ERROR:  Error installing pg:
ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -r ./siteconf20151216-5802-1na2dm0.rb extconf.rb --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config
Using config values from /Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** 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=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
--with-pg
--without-pg
--enable-windows-cross
--disable-windows-cross
--with-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}/
--with-pqlib
--without-pqlib
--with-libpqlib
--without-libpqlib
--with-ms/libpqlib
--without-ms/libpqlib

extconf failed, exit code 1

Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/pg-0.18.4 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-14/2.0.0/pg-0.18.4/gem_make.out

有人知道如何解决它吗?

我试过ARCHFLAGS =" -arch x86_64"捆绑安装 没有修好。

2 个答案:

答案 0 :(得分:3)

看起来我在3年前发现了类似的问题。安装程序无法找到它正在寻找的一些配置文件。这可能适合你。

bundle config build.pg --with-pg-config=/usr/pgsql-9.1/bin/pg_config

如果你在MacPorts上试试这个:

bundle config build.pg --with-pg-config=/opt/local/lib/postgresql91/bin/pg_config

但是,如果你正在使用brew,你可以运行

brew install postgresql

gem install pg --with-pg-config works, bundle fails

答案 1 :(得分:1)

如果你在这里使用PostgresApp,那就是命令:

gem install pg -v '0.18.4' -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.5/bin/pg_config