Can't install gem anymore on ubuntu 16.04

Issue #239 invalid
themilkman
created an issue

Hi,

I ran into an installation issue I cannot explain.

My setup:

  • Ubuntu 16.04
  • RVM ruby 2.3.1 (update also tried the ruby package without rvm - same problem)
  • Postgresql 9.5

I don't know when the issue came (installation of 2.3.1 or of Ubuntu 16.04). Now, I can't install it pg anymore at all (independent of ruby version)

Trying to solve it I did:

  • Upgrade Postgesql 9.4 -> 9.5
  • imploded my whole rvm installation
  • compiled ruby with explicit openssl-lib, with separate rvm-openssl
  • reboot ;)
  • google for the error
  • tried other versions of the gem
  • install libssl-dev
  • reinstalled libpq

I am using ruby and the pg gem for about three years, deployed on many servers etc - but never got something like that. Does anyone have an idea how to solve it?

Thanks for any response!

...

The Error while "gem install pg":

Can't find the PostgreSQL client library (libpq)
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

The (imho) relevant information in mkmf.log :

have_library: checking for PQconnectdb() in -lpq... -------------------- no

"gcc -o conftest -I/home/ee/.rvm/rubies/ruby-2.3.1/include/ruby-2.3.0/x86_64-linux -I/home/ee/.rvm/rubies/ruby-2.3.1/include/ruby-2.3.0/ruby/backward -I/home/ee/.rvm/rubies/ruby-2.3.1/include/ruby-2.3.0 -I. -I/usr/include/postgresql     -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat -Wno-maybe-uninitialized  -fPIC conftest.c  -L. -L/home/ee/.rvm/rubies/ruby-2.3.1/lib -Wl,-R/home/ee/.rvm/rubies/ruby-2.3.1/lib -L/usr/lib/x86_64-linux-gnu -Wl,-R/usr/lib/x86_64-linux-gnu -L. -fstack-protector -rdynamic -Wl,-export-dynamic     -Wl,-R/home/ee/.rvm/rubies/ruby-2.3.1/lib -L/home/ee/.rvm/rubies/ruby-2.3.1/lib -lruby -lpq  -lpthread -lgmp -ldl -lcrypt -lm   -lc"
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `SSL_CTX_use_certificate_chain_file@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `SSL_write@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `BIO_new@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `SSL_use_PrivateKey_file@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `CRYPTO_set_locking_callback@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `SSL_connect@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `BIO_clear_flags@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `CRYPTO_get_id_callback@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `BIO_set_flags@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `sk_free@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `ENGINE_init@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `X509_STORE_load_locations@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `SSL_CTX_get_cert_store@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `X509_NAME_get_entry@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `SSL_ctrl@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `SSL_free@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `SSL_library_init@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `SSL_CTX_ctrl@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `X509_NAME_ENTRY_get_data@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `ERR_get_error@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `SSL_pending@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `ENGINE_free@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `SSL_get_version@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `X509_get_subject_name@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `BIO_s_socket@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `SSL_use_certificate_file@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `CRYPTO_get_locking_callback@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `SSL_check_private_key@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `SSL_load_error_strings@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `X509_NAME_get_index_by_NID@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `BIO_int_ctrl@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `ENGINE_by_id@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `SSL_get_peer_certificate@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `SSL_CTX_new@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `sk_value@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `SSLv23_method@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `CRYPTO_num_locks@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `ERR_put_error@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `X509_get_ext_d2i@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `SSL_get_current_cipher@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `ENGINE_load_private_key@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `ENGINE_finish@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `SSL_CIPHER_get_bits@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `SSL_set_verify@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `X509_free@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `CRYPTO_set_id_callback@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `SSL_get_error@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `SSL_get_current_compression@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `SSL_new@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `SSL_shutdown@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `SSL_set_bio@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `ASN1_STRING_length@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `SSL_use_PrivateKey@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `X509_STORE_set_flags@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `SSL_read@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `OPENSSL_config@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `ASN1_STRING_data@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `SSL_CTX_load_verify_locations@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `ERR_reason_error_string@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `SSL_CIPHER_get_name@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `SSL_set_ex_data@OPENSSL_1.0.0'
/usr/lib/x86_64-linux-gnu/libpq.so: undefined reference to `sk_num@OPENSSL_1.0.0'
collect2: error: ld returned 1 exit status

Comments (8)

  1. Lars Kanis

    @themilkman Sorry not being able to help you! It seems like you build environment is broken in respect of OpenSSL.

    Since no one else had this issue, and I installed pg.gem on several Ubuntu-16.04 systems successfully, I'm going to close this ticket.

  2. top world

    $ gem install pg -v '0.21.0'

    Fetching: pg-0.21.0.gem (100%) Building native extensions. This could take a while... ERROR: Error installing pg: ERROR: Failed to build gem native extension.

    current directory: /home/topdev/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/pg-0.21.0/ext
    

    /home/topdev/.rbenv/versions/2.3.0/bin/ruby -r ./siteconf20180125-12189-qc143.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... no checking for PQconnectdb() in -llibpq... no checking for PQconnectdb() in -lms/libpq... no Can't find the PostgreSQL client library (libpq) extconf.rb failed Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options.

    Provided configuration options: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=/home/topdev/.rbenv/versions/2.3.0/bin/$(RUBY_BASE_NAME) --with-pg --without-pg --enable-windows-cross --disable-windows-cross --with-pg-config --without-pg-config --with-pg_config --without-pg_config --with-pg-dir --without-pg-dir --with-pg-include --without-pg-include=${pg-dir}/include --with-pg-lib --without-pg-lib=${pg-dir}/lib --with-pqlib --without-pqlib --with-libpqlib --without-libpqlib --with-ms/libpqlib --without-ms/libpqlib

    To see why this extension failed to compile, please check the mkmf.log which can be found here:

    /home/topdev/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0-static/pg-0.21.0/mkmf.log

    extconf failed, exit code 1

    Gem files will remain installed in /home/topdev/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/pg-0.21.0 for inspection. Results logged to /home/topdev/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0-static/pg-0.21.0/gem_make.out

  3. themilkman reporter

    Hi, just to finalize this from my side: Some time (and on a fresh OS installation...) later I got the same issue again - and understood, that I simply messed up something with the LD - pathes on my ubuntu... sorry for any confusion.

  4. Log in to comment