首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >安装pg gem时出错-- extconf.rb失败

安装pg gem时出错-- extconf.rb失败
EN

Stack Overflow用户
提问于 2015-10-14 14:11:11
回答 3查看 2.6K关注 0票数 4

在构建rails应用程序时,突然收到一条消息,说我的rails gem不见了,所以我完全重新安装了rails。然后得到了这个:

安装pg (0.18.2)时出错,Bundler无法继续。在捆绑之前,请确保gem install pg -v '0.18.2'成功。

但是运行该命令会得到以下结果:

代码语言:javascript
复制
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 -r    ./siteconf20151014-55380-170ndlh.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.

我不确定这是否相关,但大约在它开始发生的时候,我的捆绑器不能在没有sudo的情况下安装gem,这是我以前从来不需要的。

当我打开mkmf.log文件时,我得到的信息如下:

代码语言:javascript
复制
 /usr/local/Cellar/postgresql/9.4.5/include/libpq-fe.h:250:1: note:   'PQconnectdb' declared here
 extern PGconn *PQconnectdb(const char *conninfo);
 ^
 1 error generated.
 checked program was:
 /* begin */
 1: #include "ruby.h"
 2: 
 3: #include <libpq-fe.h>
 4: 
 5: /*top*/
 6: extern int t(void);
 7: int t(void) { PQconnectdb(); return 0; }
 8: int main(int argc, char **argv)
 9: {
10:   if (argc > 1000000) {
11:     printf("%p", &t);
12:   }
13: 
14:   return 0;
15: }
/* end */

--------------------

(日志更长,但这是其中有错误的尾部)。

我尝试了gem install pg — –with-pg-lib=/usr/lib,但它不起作用。

我该如何解决这个问题?谢谢!

EN

回答 3

Stack Overflow用户

发布于 2015-11-06 06:53:42

我遇到了同样的问题,并通过以下方式解决了它:

1) $ brew update

2) $ brew install postgres

2) $ gem install pg

票数 2
EN

Stack Overflow用户

发布于 2015-10-14 23:42:24

我只是发布我自己的答案,因为结果是相当出乎意料的,我尝试了我在Stackoverflow上找到的所有方法来解决它,但都没有效果。

看起来问题出在需要更新的XCode命令工具中。我更新了命令工具,然后用homebrew重新安装了postgres,并重新安装了pg gem。就像一个护身符。现在也在El Capitan上工作。

票数 0
EN

Stack Overflow用户

发布于 2020-01-23 00:24:23

对我来说,是this answer解决了这个问题:

代码语言:javascript
复制
Installing unf_ext 0.0.7.6 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /Users/luka/.rvm/gems/ruby-2.5.1/gems/unf_ext-0.0.7.6/ext/unf_ext
/Users/luka/.rvm/rubies/ruby-2.5.1/bin/ruby -r ./siteconf20200122-42541-136wsjb.rb
extconf.rb
checking for -lstdc++... *** 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.
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33117848

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档