Ruby on rails Postgres未在Bundler中安装(Ruby on Rails)

Ruby on rails Postgres未在Bundler中安装(Ruby on Rails),ruby-on-rails,postgresql,bundler,Ruby On Rails,Postgresql,Bundler,我越来越绝望了,我已经尝试了关于这个问题的每一个答案,但似乎没有任何效果 错误日志如下所示: Gem::Ext::BuildError: ERROR: Failed to build gem native extension. /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -r ./siteconf20150523-16458-46bzoo.rb extconf.rb --with-pg-conf

我越来越绝望了,我已经尝试了关于这个问题的每一个答案,但似乎没有任何效果

错误日志如下所示:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -r ./siteconf20150523-16458-46bzoo.rb extconf.rb --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config
Using config values from /Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config
sh: /Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config: No such file or directory
sh: /Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config: No such file or directory
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 /Users/kevinegstorf/.rvm/gems/ruby-2.0.0-p643/gems/pg-0.18.2 for inspection.
Results logged to /Users/kevinegstorf/.rvm/gems/ruby-2.0.0-p643/extensions/universal-darwin-14/2.0.0/pg-0.18.2/gem_make.out
An error occurred while installing pg (0.18.2), and Bundler cannot continue.
Make sure that `gem install pg -v '0.18.2'` succeeds before bundling.
安装gem install pg-v“0.18.2”会返回相同的错误
我希望有人能帮助我。tnx

您应该找到pg_config文件并将其添加到build命令中:

bundle config build.pg --with-pg-config=/usr/local/bin/pg_config
由于pg_config文件位于/usr/local/bin/pg_config,您是否尝试了上面的命令(已编辑)

如果没有帮助,可以尝试:

env ARCHFLAGS="-arch x86_64" gem install pg

如果你已经在Mac上安装了Postgres.app, 您应该将
/Applications/Postgres.app/Contents/Version/9.4/bin/pg_config
复制到另一个地方。例如
/home/pg_config

然后跑

bundle config build.pg --with-pg-config=/home/pg_config
bundle install

谢谢你的快速回复。在这个问题上,我仍然是一个不速之客。当我做“哪个pg_配置”的时候,我得到了这个。所以我只是把这个“/usr/local/bin/pg_-config”粘贴在“bundle-config build.pg--with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_-config”后面“我在运行它之后得到了这个结果,你正在用pg-config=/Applications/Postgres.app/Contents/MacOS/bin/usr/local/bin/pg_-config”替换build.pg.pg的当前全局值--”当运行bundle安装时,我收到了相同的错误消息,因为
可以找到它,这意味着它在路径中,因此问题可能是其他原因。我应该仔细查看一下,抱歉。此时无法找到postgres客户端库。你确定你已经安装了吗?你是如何安装postgres的?是的,我用的是自制的,后来我完全绝望地重新安装了rails