无法在CentOS 7虚拟机上安装 `pg` gem

3

我无法在运行CentOS 7的AWS EC2服务器上安装pg gem。 我相当自信我的Ruby安装(2.7.0),gemset,RVM等没有问题,并收到以下错误消息。如此提出了类似问题的建议,我已经安装了postgresqlpostgresql-develpostgresql-libspostgresql-server 。 Postgres是9.2.24,应该与 pg gem兼容。

我还尝试过指定 pg_conf 文件并使用命令 gem install pg -- --with-pg-config=/usr/bin/pg_config 进行安装,但收到了相同的错误。

我曾经在Mac和其他Linux系统上尝试安装 pg 时遇到过问题,但这个错误对我来说是新的。 我现在非常苦恼。

current directory: /home/MY_USERNAME/.rvm/gems/ruby-2.7.0@GEMSET_NAME/gems/pg-1.2.3/ext
/home/MY_USERNAME/.rvm/rubies/ruby-2.7.0/bin/ruby -I /home/MY_USERNAME/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0 -r ./siteconf20200714-11146-p34b9c.rb extconf.rb
checking for pg_config... yes
Using config values from /usr/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()... no
checking for PQsslAttribute()... no
checking for PQresultVerboseErrorMessage()... no
checking for PQencryptPasswordConn()... no
checking for PQresultMemorySize()... no
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: /home/MY_USERNAME/.rvm/gems/ruby-2.7.0@GEMSET_NAME/gems/pg-1.2.3/ext
make "DESTDIR=" clean

current directory: /home/MY_USERNAME/.rvm/gems/ruby-2.7.0@GEMSET_NAME/gems/pg-1.2.3/ext
make "DESTDIR="
compiling gvl_wrappers.c
compiling pg.c
compiling pg_binary_decoder.c
compiling pg_binary_encoder.c
compiling pg_coder.c
compiling pg_connection.c
compiling pg_copy_coder.c
compiling pg_errors.c
compiling pg_record_coder.c
compiling pg_result.c
compiling pg_text_decoder.c
compiling pg_text_encoder.c
compiling pg_tuple.c
compiling pg_type_map.c
compiling pg_type_map_all_strings.c
compiling pg_type_map_by_class.c
compiling pg_type_map_by_column.c
compiling pg_type_map_by_mri_type.c
compiling pg_type_map_by_oid.c
compiling pg_type_map_in_ruby.c
compiling pg_util.c
linking shared-object pg_ext.so
/usr/bin/ld: unrecognized option '--compress-debug-sections=zlib'
/usr/bin/ld: use the --help option for usage information
collect2: error: ld returned 1 exit status
make: *** [pg_ext.so] Error 1

make failed, exit code 2

我怀疑没有人愿意深入研究像PostgreSQL 9.2这样古老的软件问题。你应该尝试使用最新版本的所有软件。 - Laurenz Albe
1
错误信息似乎与ld无法识别选项有关。这是C工具链的一部分,不一定与Ruby或pg gem相关。我可以想到两种一般方法:查找gem的构建目录以找到将该参数传递给ld的位置并尝试阻止它,或尝试替换您系统的ld版本为一个可以识别该选项的版本。 - Max
谢谢@Max!问题出在ld上,升级后问题得以解决。对于类似情况的任何人,我执行了完整的sudo yum upgrade,这将升级GNU的binutils(其中ld是其中的一部分),现在我可以无问题地安装pg了。 - TheVelourFog
2个回答

1

这个链接 这里 包含对我有用的命令。具体来说,就是这些代码 -->

[ -f `/usr/pgsql-12/bin/pg_config --includedir`/libpq-fe.h ] && echo "devel installed" || echo "devel missing"
# scl-rh for llvm-toolset-7-clang 4.0.1
yum -y install centos-release-scl-rh 
yum-config-manager --disable centos-sclo-rh
yum -y install postgresql12-devel --enablerepo=centos-sclo-rh

1
我从Max的回复中找到了答案。
问题出在ld上,而不是postgres。我的ld版本(ld -v)过时了,我进行了完整的系统升级(sudo yum upgrade),升级了GNU的binutils(其中包括ld),现在我可以无问题地安装pg了。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接