postgresql 在mac芯片上使用ARCHFLAGS安装pg -v 1.2.3

s4n0splo  于 2023-08-04  发布在  PostgreSQL
关注(0)|答案(1)|浏览(139)

问题总结

我正在遵循一些设置说明,其中包含以下步骤:

ARCHFLAGS="-arch x86_64" gem install pg -v 1.2.3

字符串
一个问题似乎与我运行的MacBookPro与M1芯片有关,每this SO thread
预期的结果大概是成功安装的pg gem(版本1.2.3)
相反,我看到的错误,我认为是有关的不同文件路径之间使用的英特尔和苹果芯片。

Building native extensions. This could take a while...
ERROR:  Error installing pg:
    ERROR: Failed to build gem native extension.

    current directory: /Users/JRBOBDOBBS/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/pg-1.2.3/ext
/Users/JRBOBDOBBS/.rbenv/versions/3.2.2/bin/ruby extconf.rb
checking for pg_config... yes
Using config values from /Applications/Postgres.app/Contents/Versions/latest/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... yes
checking for PQsetSingleRowMode()... yes
checking for PQconninfo()... yes
checking for PQsslAttribute()... yes
checking for PQresultVerboseErrorMessage()... yes
checking for PQencryptPasswordConn()... yes
checking for PQresultMemorySize()... yes
checking for timegm()... yes
checking for rb_gc_adjust_memory_usage()... yes
checking for unistd.h... yes
checking for inttypes.h... yes
checking for C99 variable length arrays... yes
creating extconf.h
creating Makefile

current directory: /Users/JRBOBDOBBS/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/pg-1.2.3/ext
make DESTDIR\= sitearchdir\=./.gem.20230720-5310-17fm3z sitelibdir\=./.gem.20230720-5310-17fm3z clean

current directory: /Users/JRBOBDOBBS/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/pg-1.2.3/ext
make DESTDIR\= sitearchdir\=./.gem.20230720-5310-17fm3z sitelibdir\=./.gem.20230720-5310-17fm3z
compiling gvl_wrappers.c
In file included from gvl_wrappers.c:6:
In file included from ./pg.h:61:
/Applications/Postgres.app/Contents/Versions/15/include/pg_config_manual.h:85:5: warning: 'SIZEOF_VOID_P' is not defined, evaluates to 0 [-Wundef]
#if SIZEOF_VOID_P >= 8
    ^
/Applications/Postgres.app/Contents/Versions/15/include/pg_config_manual.h:168:5: warning: 'HAVE_DECL_POSIX_FADVISE' is not defined, evaluates to 0 [-Wundef]
#if HAVE_DECL_POSIX_FADVISE && defined(HAVE_POSIX_FADVISE)
    ^
2 warnings generated.
compiling pg.c
In file included from pg.c:49:
In file included from ./pg.h:61:
/Applications/Postgres.app/Contents/Versions/15/include/pg_config_manual.h:85:5: warning: 'SIZEOF_VOID_P' is not defined, evaluates to 0 [-Wundef]
#if SIZEOF_VOID_P >= 8
    ^
/Applications/Postgres.app/Contents/Versions/15/include/pg_config_manual.h:168:5: warning: 'HAVE_DECL_POSIX_FADVISE' is not defined, evaluates to 0 [-Wundef]
#if HAVE_DECL_POSIX_FADVISE && defined(HAVE_POSIX_FADVISE)
    ^
2 warnings generated.
compiling pg_binary_decoder.c
In file included from pg_binary_decoder.c:8:
In file included from ./pg.h:61:
/Applications/Postgres.app/Contents/Versions/15/include/pg_config_manual.h:85:5: warning: 'SIZEOF_VOID_P' is not defined, evaluates to 0 [-Wundef]
#if SIZEOF_VOID_P >= 8
    ^
/Applications/Postgres.app/Contents/Versions/15/include/pg_config_manual.h:168:5: warning: 'HAVE_DECL_POSIX_FADVISE' is not defined, evaluates to 0 [-Wundef]
#if HAVE_DECL_POSIX_FADVISE && defined(HAVE_POSIX_FADVISE)
    ^
2 warnings generated.
compiling pg_binary_encoder.c
In file included from pg_binary_encoder.c:7:
In file included from ./pg.h:61:
/Applications/Postgres.app/Contents/Versions/15/include/pg_config_manual.h:85:5: warning: 'SIZEOF_VOID_P' is not defined, evaluates to 0 [-Wundef]
#if SIZEOF_VOID_P >= 8
    ^
/Applications/Postgres.app/Contents/Versions/15/include/pg_config_manual.h:168:5: warning: 'HAVE_DECL_POSIX_FADVISE' is not defined, evaluates to 0 [-Wundef]
#if HAVE_DECL_POSIX_FADVISE && defined(HAVE_POSIX_FADVISE)
    ^
2 warnings generated.
compiling pg_coder.c
In file included from pg_coder.c:6:
In file included from ./pg.h:61:
/Applications/Postgres.app/Contents/Versions/15/include/pg_config_manual.h:85:5: warning: 'SIZEOF_VOID_P' is not defined, evaluates to 0 [-Wundef]
#if SIZEOF_VOID_P >= 8
    ^
/Applications/Postgres.app/Contents/Versions/15/include/pg_config_manual.h:168:5: warning: 'HAVE_DECL_POSIX_FADVISE' is not defined, evaluates to 0 [-Wundef]
#if HAVE_DECL_POSIX_FADVISE && defined(HAVE_POSIX_FADVISE)
    ^
pg_coder.c:216:34: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
        res = this->dec_func(this, val, RSTRING_LEN(argv[0]), tuple, field, ENCODING_GET(argv[0]));
              ~~~~                      ^~~~~~~~~~~~~~~~~~~~
/Users/JRBOBDOBBS/.rbenv/versions/3.2.2/include/ruby-3.2.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
3 warnings generated.
compiling pg_connection.c
In file included from pg_connection.c:7:
In file included from ./pg.h:61:
/Applications/Postgres.app/Contents/Versions/15/include/pg_config_manual.h:85:5: warning: 'SIZEOF_VOID_P' is not defined, evaluates to 0 [-Wundef]
#if SIZEOF_VOID_P >= 8
    ^
/Applications/Postgres.app/Contents/Versions/15/include/pg_config_manual.h:168:5: warning: 'HAVE_DECL_POSIX_FADVISE' is not defined, evaluates to 0 [-Wundef]
#if HAVE_DECL_POSIX_FADVISE && defined(HAVE_POSIX_FADVISE)
    ^
pg_connection.c:679:17: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
        return INT2NUM(atol(port));
               ~~~~~~~ ^~~~~~~~~~
3 warnings generated.
compiling pg_copy_coder.c
In file included from pg_copy_coder.c:6:
In file included from ./pg.h:61:
/Applications/Postgres.app/Contents/Versions/15/include/pg_config_manual.h:85:5: warning: 'SIZEOF_VOID_P' is not defined, evaluates to 0 [-Wundef]
#if SIZEOF_VOID_P >= 8
    ^
/Applications/Postgres.app/Contents/Versions/15/include/pg_config_manual.h:168:5: warning: 'HAVE_DECL_POSIX_FADVISE' is not defined, evaluates to 0 [-Wundef]
#if HAVE_DECL_POSIX_FADVISE && defined(HAVE_POSIX_FADVISE)
    ^
pg_copy_coder.c:228:15: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
                                        strlen = RSTRING_LEN(subint);
                                               ~ ^~~~~~~~~~~~~~~~~~~
/Users/JRBOBDOBBS/.rbenv/versions/3.2.2/include/ruby-3.2.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
pg_copy_coder.c:534:23: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
                input_len = end_ptr - start_ptr;
                          ~ ~~~~~~~~^~~~~~~~~~~
4 warnings generated.
compiling pg_errors.c
In file included from pg_errors.c:6:
In file included from ./pg.h:61:
/Applications/Postgres.app/Contents/Versions/15/include/pg_config_manual.h:85:5: warning: 'SIZEOF_VOID_P' is not defined, evaluates to 0 [-Wundef]
#if SIZEOF_VOID_P >= 8
    ^
/Applications/Postgres.app/Contents/Versions/15/include/pg_config_manual.h:168:5: warning: 'HAVE_DECL_POSIX_FADVISE' is not defined, evaluates to 0 [-Wundef]
#if HAVE_DECL_POSIX_FADVISE && defined(HAVE_POSIX_FADVISE)
    ^
2 warnings generated.
compiling pg_record_coder.c
In file included from pg_record_coder.c:6:
In file included from ./pg.h:61:
/Applications/Postgres.app/Contents/Versions/15/include/pg_config_manual.h:85:5: warning: 'SIZEOF_VOID_P' is not defined, evaluates to 0 [-Wundef]
#if SIZEOF_VOID_P >= 8
    ^
/Applications/Postgres.app/Contents/Versions/15/include/pg_config_manual.h:168:5: warning: 'HAVE_DECL_POSIX_FADVISE' is not defined, evaluates to 0 [-Wundef]
#if HAVE_DECL_POSIX_FADVISE && defined(HAVE_POSIX_FADVISE)
    ^
pg_record_coder.c:196:15: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
                                        strlen = RSTRING_LEN(subint);
                                               ~ ^~~~~~~~~~~~~~~~~~~
/Users/JRBOBDOBBS/.rbenv/versions/3.2.2/include/ruby-3.2.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
3 warnings generated.
compiling pg_result.c
In file included from pg_result.c:7:
In file included from ./pg.h:61:
/Applications/Postgres.app/Contents/Versions/15/include/pg_config_manual.h:85:5: warning: 'SIZEOF_VOID_P' is not defined, evaluates to 0 [-Wundef]
#if SIZEOF_VOID_P >= 8
    ^
/Applications/Postgres.app/Contents/Versions/15/include/pg_config_manual.h:168:5: warning: 'HAVE_DECL_POSIX_FADVISE' is not defined, evaluates to 0 [-Wundef]
#if HAVE_DECL_POSIX_FADVISE && defined(HAVE_POSIX_FADVISE)
    ^
pg_result.c:1006:17: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
        return INT2NUM(n);
               ~~~~~~~ ^
pg_result.c:1590:58: error: use of undeclared identifier 'rb_cData'
        rb_cPGresult = rb_define_class_under( rb_mPG, "Result", rb_cData );
                                                                ^
3 warnings and 1 error generated.
make: *** [pg_result.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/JRBOBDOBBS/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/pg-1.2.3 for inspection.
Results logged to /Users/JRBOBDOBBS/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/extensions/arm64-darwin-20/3.2.0/pg-1.2.3/gem_make.out

我尝试过:

1.根据我上面链接的文章,我尝试了这个:

ARCHFLAGS="-arch $(uname -m)" gem install pg -v 1.2.3


我认为这是一个相当巧妙的即兴表演;唉,没有骰子
1.同样的事情,但没有插值
我考虑放弃ARCHFLAGS位,因为说到底,这不是简单地试图安装pg的1.2.3版本吗?

我的问题

  • 在带有M1芯片的MacBookPro上使用ARCHFLAGS变量的正确、明确的命令是什么?*

或者更重要的是:

  • 我是否需要对ARCHFLAGS变量大惊小怪?*

编辑1:

我找到了this solution to a similar issue并完成了以下步骤:

brew install libpq
export PATH="/opt/homebrew/opt/libpq/bin:$PATH
gem install pg


它安装成功了,但那是pg -v 1. 5. 3(如果我使用-v 1. 2. 3真的有关系吗?)

ddarikpa

ddarikpa1#

拥有libpq是正确的方法来做到这一点,没有-没有理由使用少于最新的pg,除非你有一个特定的理由这样做(例如。旧的/遗留项目)。
此外,正如我认为您已经意识到的,基于您的ARCHFLAGS="-arch $(uname -m)"示例(非常漂亮),使用amd 64芯片的x86标志(即x86标志)。Mac M1/M2永远不会工作。

相关问题