![](/img/trans.png)
[英]"Error installing rails" because "extconf.rb failed" on Ubuntu 18.04
[英]Error installing pg gem -- extconf.rb failed
在构建 rails 应用程序时,突然收到消息说我的 rails gem 不见了,所以我完全重新安装了 rails。 然后得到了这个:
安装 pg (0.18.2) 时出错,Bundler 无法继续。 在捆绑之前确保gem install pg -v '0.18.2'
成功。
但是运行命令让我得到这个:
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 文件时,我得到以下信息:
/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
,但没有用。
我该如何解决? 谢谢!
我遇到了同样的问题并通过以下方式修复了它:
1) $ brew update
2) $ brew install postgres
2) $ gem install pg
只是发布我自己的答案,因为解决方案出乎意料,我尝试了在 Stackoverflow 上找到的所有方法来解决它,但无济于事。
看起来问题出在需要更新的 XCode 命令工具中。 我更新了命令工具,然后用自制软件重新安装了 postgres,并重新安装了 pg gem。 像魅力一样工作。 现在也适用于 El Capitan。
对我来说,正是这个答案解决了:
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.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.