MAC M1 ARM Core - Ruby 和 Gem pg 安装问题

Aks*_*pal 5 ruby macos homebrew rubygems pg

只是想发布一个问题,我gem install pg -v '0.21.0'在 M1 Mac 系统中安装 2 个项目时遇到问题,有人遇到过这样的问题吗

这是我收到的错误

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 ***
Run Code Online (Sandbox Code Playgroud)

Postgres 是通过 Homebrew 安装的,并且还安装了 libpq,我尝试在安装 gem pg 时指向 libpq 并尝试解决问题,但这也不起作用,附加 mkmf 日志以获取有关错误的更多详细信息,仅供参考 Postgres 是安装后,我还可以通过终端和其他软件连接到它。我从堆栈中尝试了很多答案都无济于事我对 Ruby 和 MAC 很陌生,任何帮助都会很棒

更多信息,但不确定安装 ruby​​ 版本 2.5.0 和 2.3.6 时是否存在相关问题,但现已修复(之前显示为已损坏,因此将其清除并在手动将 openssl@1.0 手动配置到 MAC 后再次安装),但当它被损坏时pg 和捆绑安装对于我的一个项目都运行良好,但 Ruby 2.3.6 版本安装失败

编辑1

ruby -v
ruby 2.3.6p384 (2017-12-14 revision 61254) [x86_64-darwin20]
which ruby
/Users/akshayvenugopal/.rvm/rubies/ruby-2.3.6/bin/ruby
rvm list
=* ruby-2.3.6 [ x86_64 ]
   ruby-2.5.0 [ x86_64 ]
which openssl
/usr/local/opt/openssl@1.0/bin/openssl
postgres --version
postgres (PostgreSQL) 14.0
Run Code Online (Sandbox Code Playgroud)

编辑2

nokogiri 也遇到了问题,不确定这是否是问题所在

如果您需要更多信息,请告诉我任何帮助,我们将不胜感激

MKMF日志

find_executable: checking for pg_config... -------------------- yes

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

"gcc -o conftest -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/x86_64-darwin20 -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/backward -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0 -I. -I/opt/homebrew/opt/libpq/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -O3 -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wmisleading-indentation -Wextra-tokens  -fno-common -pipe conftest.c  -L. -L/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/lib -L/opt/homebrew/opt/libpq/lib -L. -fstack-protector     -lruby.2.5.0  -lpthread -ldl -lobjc "
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

"gcc -o conftest -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/x86_64-darwin20 -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/backward -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0 -I. -I/opt/homebrew/opt/libpq/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -O3 -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wmisleading-indentation -Wextra-tokens  -fno-common -pipe conftest.c  -L. -L/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/lib -L/opt/homebrew/opt/libpq/lib -L. -fstack-protector     -lruby.2.5.0  -Wl,-rpath,/opt/homebrew/opt/libpq/lib -lpthread -ldl -lobjc "
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main() {return 0;}
/* end */

find_header: checking for libpq-fe.h... -------------------- yes

"gcc -E -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/x86_64-darwin20 -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/backward -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0 -I. -I/opt/homebrew/opt/libpq/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -O3 -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wmisleading-indentation -Wextra-tokens  -fno-common -pipe  conftest.c -o conftest.i"
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <libpq-fe.h>
/* end */

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

find_header: checking for libpq/libpq-fs.h... -------------------- yes

"gcc -E -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/x86_64-darwin20 -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/backward -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0 -I. -I/opt/homebrew/opt/libpq/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -O3 -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wmisleading-indentation -Wextra-tokens  -fno-common -pipe  conftest.c -o conftest.i"
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <libpq/libpq-fs.h>
/* end */

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

find_header: checking for pg_config_manual.h... -------------------- yes

"gcc -E -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/x86_64-darwin20 -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/backward -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0 -I. -I/opt/homebrew/opt/libpq/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -O3 -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wmisleading-indentation -Wextra-tokens  -fno-common -pipe  conftest.c -o conftest.i"
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <pg_config_manual.h>
/* end */

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

have_library: checking for PQconnectdb() in -lpq... -------------------- no

"gcc -o conftest -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/x86_64-darwin20 -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/backward -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0 -I. -I/opt/homebrew/opt/libpq/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -O3 -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wmisleading-indentation -Wextra-tokens  -fno-common -pipe conftest.c  -L. -L/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/lib -L/opt/homebrew/opt/libpq/lib -L. -fstack-protector -Wl,-rpath,/opt/homebrew/opt/libpq/lib     -lruby.2.5.0 -lpq  -lpthread -ldl -lobjc "
ld: warning: ignoring file /opt/homebrew/opt/libpq/lib/libpq.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
Undefined symbols for architecture x86_64:
  "_PQconnectdb", referenced from:
      _t in conftest-f3b0c7.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: #include <libpq-fe.h>
 4: 
 5: /*top*/
 6: extern int t(void);
 7: int main(int argc, char **argv)
 8: {
 9:   if (argc > 1000000) {
10:     printf("%p", &t);
11:   }
12: 
13:   return 0;
14: }
15: int t(void) { void ((*volatile p)()); p = (void ((*)()))PQconnectdb; return !p; }
/* end */

"gcc -o conftest -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/x86_64-darwin20 -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/backward -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0 -I. -I/opt/homebrew/opt/libpq/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -O3 -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wmisleading-indentation -Wextra-tokens  -fno-common -pipe conftest.c  -L. -L/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/lib -L/opt/homebrew/opt/libpq/lib -L. -fstack-protector -Wl,-rpath,/opt/homebrew/opt/libpq/lib     -lruby.2.5.0 -lpq  -lpthread -ldl -lobjc "
conftest.c:15:13: error: conflicting types for 'PQconnectdb'
extern void PQconnectdb();
            ^
/opt/homebrew/opt/libpq/include/libpq-fe.h:285:16: note: previous declaration is here
extern PGconn *PQconnectdb(const char *conninfo);
               ^
conftest.c:16:27: error: too few arguments to function call, single argument 'conninfo' was not specified
int t(void) { PQconnectdb(); return 0; }
              ~~~~~~~~~~~ ^
/opt/homebrew/opt/libpq/include/libpq-fe.h:285:16: note: 'PQconnectdb' declared here
extern PGconn *PQconnectdb(const char *conninfo);
               ^
2 errors 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 main(int argc, char **argv)
 8: {
 9:   if (argc > 1000000) {
10:     printf("%p", &t);
11:   }
12: 
13:   return 0;
14: }
15: extern void PQconnectdb();
16: int t(void) { PQconnectdb(); return 0; }
/* end */

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

have_library: checking for PQconnectdb() in -llibpq... -------------------- no

"gcc -o conftest -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/x86_64-darwin20 -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/backward -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0 -I. -I/opt/homebrew/opt/libpq/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -O3 -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wmisleading-indentation -Wextra-tokens  -fno-common -pipe conftest.c  -L. -L/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/lib -L/opt/homebrew/opt/libpq/lib -L. -fstack-protector -Wl,-rpath,/opt/homebrew/opt/libpq/lib     -lruby.2.5.0 -llibpq  -lpthread -ldl -lobjc "
ld: library not found for -llibpq
clang: error: linker command failed with exit code 1 (use -v to see invocation)
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: #include <libpq-fe.h>
 4: 
 5: /*top*/
 6: extern int t(void);
 7: int main(int argc, char **argv)
 8: {
 9:   if (argc > 1000000) {
10:     printf("%p", &t);
11:   }
12: 
13:   return 0;
14: }
15: int t(void) { void ((*volatile p)()); p = (void ((*)()))PQconnectdb; return !p; }
/* end */

"gcc -o conftest -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/x86_64-darwin20 -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/backward -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0 -I. -I/opt/homebrew/opt/libpq/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -O3 -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wmisleading-indentation -Wextra-tokens  -fno-common -pipe conftest.c  -L. -L/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/lib -L/opt/homebrew/opt/libpq/lib -L. -fstack-protector -Wl,-rpath,/opt/homebrew/opt/libpq/lib     -lruby.2.5.0 -llibpq  -lpthread -ldl -lobjc "
conftest.c:15:13: error: conflicting types for 'PQconnectdb'
extern void PQconnectdb();
            ^
/opt/homebrew/opt/libpq/include/libpq-fe.h:285:16: note: previous declaration is here
extern PGconn *PQconnectdb(const char *conninfo);
               ^
conftest.c:16:27: error: too few arguments to function call, single argument 'conninfo' was not specified
int t(void) { PQconnectdb(); return 0; }
              ~~~~~~~~~~~ ^
/opt/homebrew/opt/libpq/include/libpq-fe.h:285:16: note: 'PQconnectdb' declared here
extern PGconn *PQconnectdb(const char *conninfo);
               ^
2 errors 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 main(int argc, char **argv)
 8: {
 9:   if (argc > 1000000) {
10:     printf("%p", &t);
11:   }
12: 
13:   return 0;
14: }
15: extern void PQconnectdb();
16: int t(void) { PQconnectdb(); return 0; }
/* end */

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

have_library: checking for PQconnectdb() in -lms/libpq... -------------------- no

"gcc -o conftest -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/x86_64-darwin20 -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/backward -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0 -I. -I/opt/homebrew/opt/libpq/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -O3 -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wmisleading-indentation -Wextra-tokens  -fno-common -pipe conftest.c  -L. -L/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/lib -L/opt/homebrew/opt/libpq/lib -L. -fstack-protector -Wl,-rpath,/opt/homebrew/opt/libpq/lib     -lruby.2.5.0 -lms/libpq  -lpthread -ldl -lobjc "
ld: library not found for -lms/libpq
clang: error: linker command failed with exit code 1 (use -v to see invocation)
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: #include <libpq-fe.h>
 4: 
 5: /*top*/
 6: extern int t(void);
 7: int main(int argc, char **argv)
 8: {
 9:   if (argc > 1000000) {
10:     printf("%p", &t);
11:   }
12: 
13:   return 0;
14: }
15: int t(void) { void ((*volatile p)()); p = (void ((*)()))PQconnectdb; return !p; }
/* end */

"gcc -o conftest -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/x86_64-darwin20 -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/backward -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0 -I. -I/opt/homebrew/opt/libpq/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -O3 -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wmisleading-indentation -Wextra-tokens  -fno-common -pipe conftest.c  -L. -L/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/lib -L/opt/homebrew/opt/libpq/lib -L. -fstack-protector -Wl,-rpath,/opt/homebrew/opt/libpq/lib     -lruby.2.5.0 -lms/libpq  -lpthread -ldl -lobjc "
conftest.c:15:13: error: conflicting types for 'PQconnectdb'
extern void PQconnectdb();
            ^
/opt/homebrew/opt/libpq/include/libpq-fe.h:285:16: note: previous declaration is here
extern PGconn *PQconnectdb(const char *conninfo);
               ^
conftest.c:16:27: error: too few arguments to function call, single argument 'conninfo' was not specified
int t(void) { PQconnectdb(); return 0; }
              ~~~~~~~~~~~ ^
/opt/homebrew/opt/libpq/include/libpq-fe.h:285:16: note: 'PQconnectdb' declared here
extern PGconn *PQconnectdb(const char *conninfo);
               ^
2 errors 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 main(int argc, char **argv)
 8: {
 9:   if (argc > 1000000) {
10:     printf("%p", &t);
11:   }
12: 
13:   return 0;
14: }
15: extern void PQconnectdb();
16: int t(void) { PQconnectdb(); return 0; }
/* end */

--------------------
Run Code Online (Sandbox Code Playgroud)