【问题标题】:libpq native extension crashed on ruby on railslibpq 本机扩展在 ruby​​ on rails 上崩溃
【发布时间】:2016-05-05 06:50:45
【问题描述】:

我正在尝试在我的 Mac 上安装 pg ( postgreSQL gem ) 并收到此错误

  Installing pg 0.18.1 with native extensions

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

  current directory: /private/var/folders/h5/slvxw4xd0d30dxzxf8vg5c600000gp/T/bundler20160302-7420-1orffo8pg-0.18.1/gems/pg-0.18.1/ext
  /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -r ./siteconf20160302-7420-h4zq8h.rb 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

  To see why this extension failed to compile, please check the mkmf.log which can be found here:

    /var/folders/h5/slvxw4xd0d30dxzxf8vg5c600000gp/T/bundler20160302-7420-1orffo8pg-0.18.1/extensions/universal-darwin-15/2.0.0/pg-0.18.1/mkmf.log

  extconf failed, exit code 1

  Gem files will remain installed in /var/folders/h5/slvxw4xd0d30dxzxf8vg5c600000gp/T/bundler20160302-7420-1orffo8pg-0.18.1/gems/pg-0.18.1 for inspection.
  Results logged to /var/folders/h5/slvxw4xd0d30dxzxf8vg5c600000gp/T/bundler20160302-7420-1orffo8pg-0.18.1/extensions/universal-darwin-15/2.0.0/pg-0.18.1/gem_make.out

所以我检查了我安装的所有软件包:

Mac OS X El Capitan v10.11.3

$ruby -v
-> ruby 2.0.0p645 (2015-04-13 revision 50299) [universal.x86_64-darwin15]
$rails -v    
-> Rails 4.2.5.1
$brew -v
-> Homebrew 0.9.5 (git revision c9aee; last commit 2016-02-15)
$benv -v
-> rbenv 0.4.0
$postgres -V    
-> postgres (PostgreSQL) 9.4.5
$xcode-select -p
/Applications/Xcode.app/Contents/Developer
$gcc --version
-> Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
    Apple LLVM version 7.0.2 (clang-700.1.81)
    Target: x86_64-apple-darwin15.3.0
    Thread model: posix

我不想通过浏览器应用程序下载安装 postgre,我想通过 brew 包安装,所以有办法安装烦人的 libpq 吗?

【问题讨论】:

标签: ruby-on-rails postgresql libpq


【解决方案1】:

你不应该需要 libpq 来让 postgres 在 Mac OSX 上使用 ruby​​。

如果您使用Postgres.app 安装了 postgres,您可以通过简单地将 postgres.app 移动到垃圾箱并从 ~/Library/Application Support/Postgres 删除数据目录来删除它(仅当您想删除所有现有的 postgres 数据库时)你的机器)

然后,使用自制软件,通过brew install postgresql 安装 postgres。 pg gem 应该直接与 postgres Homebrew 安装一起使用。

【讨论】:

  • 我的笔记本电脑是全新的,有任何数据库,我还没有通过应用程序安装 postgre,我是通过 bre install postgresql 安装的,当我尝试开始一个新的 rails 项目时...... booom !!由于 libpq 导致一切崩溃:S
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-02-28
  • 2011-03-25
  • 1970-01-01
  • 2011-11-08
  • 1970-01-01
  • 2014-08-23
相关资源
最近更新 更多