我一直在尝试在我的电脑上(Macbook Pro 2020 with M1)安装一个rails项目,运行的是Big Sur操作系统。
我已经安装了PostgresApp。
当运行 bundle install
时,它无法构建 pg
gem,所以我尝试手动安装gem(通过执行 gem install pg
- 也尝试过用 gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/10/bin/pg_config
命令)。
我收到一个错误消息,内容如下:
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
Can't find the PostgreSQL client library (libpq)
*** extconf.rb failed ***
当检查错误日志时,我看到:
have_library: checking for PQconnectdb() in -lpq... -------------------- no
ld: warning: ignoring file /Applications/Postgres.app/Contents/Versions/13/lib/libpq.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
Undefined symbols for architecture arm64:
"_PQconnectdb", referenced from:
_t in conftest-db479f.o
ld: symbol(s) not found for architecture arm64
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 */
有什么想法可以解决这个问题吗?