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. I have installed postgresql
, postgresql-devel
, postgresql-libs
, and postgresql-server
as suggested in similar questions on here. Postgres is 9.2.24 which should be compatible with the 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.
I’ve encountered issues in the past attempting to install pg
on Mac and other Linux systems, but this error is new to me. 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
2
Answers
I found the answer from Max's reply.
The issue was with
ld
, not postgres. Myld
version (ld -v
was antiquated and I did a full system upgrade (sudo yum upgrade
) which upgraded GNU'sbinutils
(of whichld
is a part) and now I can installpg
without issue.This link here contained commands that worked for me. Specifically these lines –>