简体   繁体   English

无法在 CentOS 7 VM 上安装“pg”gem

[英]Unable to install `pg` gem on CentOS 7 VM

I'm unable to install the pg gem on an AWS EC2 server running CentOS 7. I'm reasonably confident there are no issues with my Ruby install (2.7.0), gemset, RVM, etc.. and am receiving the error message below.我无法在运行 CentOS 7 的 AWS EC2 服务器上安装pg gem。我有理由相信我的 Ruby 安装 (2.7.0)、gemset、RVM 等没有问题。并且正在收到错误消息以下。 I have installed postgresql , postgresql-devel , postgresql-libs , and postgresql-server as suggested in similar questions on here.我已经按照此处类似问题中的建议安装了postgresqlpostgresql-develpostgresql-libspostgresql-server Postgres is 9.2.24 which should be compatible with the pg gem. Postgres 是 9.2.24,应该与pg gem 兼容。

I have also tried specifying the pg_conf file and installing with the command gem install pg -- --with-pg-config=/usr/bin/pg_config and received the same error.我还尝试指定pg_conf文件并使用命令gem install pg -- --with-pg-config=/usr/bin/pg_config并收到相同的错误。

I've encountered issues in the past attempting to install pg on Mac and other Linux systems, but this error is new to me.我过去尝试在 Mac 和其他 Linux 系统上安装pg时遇到过问题,但这个错误对我来说是新的。 I'm hitting my head against the wall.我正用头撞墙。

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

I found the answer from Max's reply .我从Max 的回复中找到了答案。

The issue was with ld , not postgres.问题出在ld上,而不是 postgres 上。 My ld version ( ld -v was antiquated and I did a full system upgrade ( sudo yum upgrade ) which upgraded GNU's binutils (of which ld is a part) and now I can install pg without issue.我的ld版本( ld -v已经过时了,我做了一个完整的系统升级( sudo yum upgrade ),它升级了 GNU 的binutils (其中ld是其中的一部分),现在我可以毫无问题地安装pg了。

This link here contained commands that worked for me. 此处的此链接包含对我有用的命令。 Specifically these lines -->特别是这些行-->

[ -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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM