簡體   English   中英

安裝 pg gem 時出錯 -- extconf.rb 失敗

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM