新手问题 关于 bundle 的一个弱弱的问题

knight · 2015年02月10日 · 最后由 knight 回复于 2015年02月11日 · 4199 次阅读

就是吧 运行 bundle install 总是出现

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb 
checking for pg_config... yes
Using config values from /usr/local/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
    --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}/
    --with-pqlib
    --without-pqlib
    --with-libpqlib
    --without-libpqlib
    --with-ms/libpqlib
    --without-ms/libpqlib


Gem files will remain installed in /var/folders/yy/8cck9sl93f97xz4qbv4wtxth0000gn/T/bundler20150210-1783-1x6bqzr/pg-0.18.1/gems/pg-0.18.1 for inspection.
Results logged to /var/folders/yy/8cck9sl93f97xz4qbv4wtxth0000gn/T/bundler20150210-1783-1x6bqzr/pg-0.18.1/gems/pg-0.18.1/ext/gem_make.out
An error occurred while installing pg (0.18.1), and Bundler cannot continue.
Make sure that `gem install pg -v '0.18.1'` succeeds before bundling.

运行 gem install pg -v 0.18.1

又出现

Building native extensions.  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 extconf.rb
checking for pg_config... yes
Using config values from /usr/local/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
    --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}/
    --with-pqlib
    --without-pqlib
    --with-libpqlib
    --without-libpqlib
    --with-ms/libpqlib
    --without-ms/libpqlib


Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/pg-0.18.1 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/gems/pg-0.18.1/ext/gem_make.out

thx

Can't find the PostgreSQL client library (libpq)

找不到 libpq 这个库,根据你安装 PostgreSQL 的方式不同,可能 libpq 是另外打包的,看看你安装 PostgreSQL 的方式的相关说明。

例如在 Ubuntu 下,要:

sudo apt-get install postgresql libpq-dev

#1 楼 @Rei 我是 Mac 大神求解决!我是直接 Brew install postgresql。如果我英语老师不是体育老师教的,我一定可以 Google 出来

@knight 如何直接brew install postgresql的话 libpg 应该是安装了的,你可以把 pg 卸载了重装一下。

#3 楼 @ailen brew install postgresql --without--ossp--uuid 我当时也想过 libpg 如果是 brew 应该 pg 是安装的 我在 ruby cn 也 看过类似解决方案 https://ruby-china.org/topics/16066 卸载 postgresql 然后 brew install postgresql 然后 gem install pg -v 0.18.1 但是我在 library/ruby/gem/2.0.0/gems/pg-0.18.1确实找到了这个目录 里面确实也有东西。

按照他说的方法 还是会提示缺少 libpg

需要 登录 后方可回复, 如果你还没有账号请 注册新账号