安装pg成功,但是bundle安装失败。

4

关于这个问题,有很多话题,但我已经尝试了几乎所有的方法,都没有成功。

我使用的是 Mac OS X 10.9.4 Mavericks,我安装了 Postgres.app,并且它似乎运行良好。 sudo gem install pg 也可以正常工作:

Building native extensions.  This could take a while...
Successfully installed pg-0.17.1
invalid options: -f fivefish
(invalid options are ignored)
Parsing documentation for pg-0.17.1
Done installing documentation for pg after 2 seconds
1 gem installed

但是当我尝试运行bundle install时,我遇到了和其他人一样的错误。
  • 我已经尝试过bundle config build.pg --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config,然后运行bundle install

  • 我已经安装了Xcode命令行工具。

  • which psql返回/Applications/Postgres.app/Contents/Versions/9.3/bin/psql

  • which postgres返回/Applications/Postgres.app/Contents/Versions/9.3/bin/postgres

这里是bundle install的错误信息:

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

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby 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
    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
    --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 /var/folders/07/my1cl5xj7g9cknnp3y2zg_rh0000gn/T/bundler20140723-29399-1o0uzqn/pg-0.17.1/gems/pg-0.17.1 for inspection.
Results logged to /var/folders/07/my1cl5xj7g9cknnp3y2zg_rh0000gn/T/bundler20140723-29399-1o0uzqn/pg-0.17.1/extensions/universal-darwin-13/2.0.0/pg-0.17.1/gem_make.out
An error occurred while installing pg (0.17.1), and Bundler cannot continue.
Make sure that `gem install pg -v '0.17.1'` succeeds before bundling.
2个回答

2

经过几天的努力,我终于找到了问题的根源(具有讽刺意味的是,当我决定放弃并继续前进时)。

当我执行 which bundlewhich gem 时,它们不是来自同一个Ruby安装。 bundle 来自 rbenv,而gem来自Mac OSX预装的Ruby。


你能详细说明一下吗?我也遇到了同样的问题 - 你采取了哪些步骤来解决它? - Ken
如果我的记忆没错的话,我用rbenv重新安装了所有的gem bundle。https://dev59.com/kGQo5IYBdhLWcg3wDb0J - Nicolas Vergoz

0

可能存在权限问题。可以使用以下命令:

sudo bundle install --without nothing --path vendor/cache


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接