0

In ubuntu 14.04 I can't install pg gem, however I installed the libpg-dev as well.

sudo apt-get install libpq-dev

Here I can see some other people have the same issue.

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

    /home/user/.rvm/rubies/ruby-1.9.3-p194/bin/ruby -r ./siteconf20141202-24533-1xrmav0.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/user/.rvm/rubies/ruby-1.9.3-p194/bin/ruby
    --with-pg
    --without-pg
    --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

extconf failed, exit code 1

Gem files will remain installed in /home/user/.rvm/gems/ruby-1.9.3-p194/gems/pg-0.17.1 for inspection.
Results logged to /home/user/.rvm/gems/ruby-1.9.3-p194/extensions/x86_64-linux/1.9.1/pg-0.17.1/gem_make.out

any help?

5
  • strange problem...i don't know, but try ruby sudo ldconfig, then try again Commented Dec 2, 2014 at 15:29
  • Yeah, its still the same. Commented Dec 2, 2014 at 15:32
  • What's the output of dpkg -S /usr/lib/libpq.so? Commented Dec 2, 2014 at 15:44
  • dpkg -S /usr/lib/libpq.so returns libpq-dev: /usr/lib/libpq.so Commented Dec 2, 2014 at 15:50
  • could you do sudo grep PQconnectdb /usr/lib/libpq.so? Commented Dec 2, 2014 at 17:18

4 Answers 4

4

Run this code sudo ARCHFLAGS="-arch x86_64" gem install pg -v '0.18.2' then bundle install. It should install the pg gem correctly.

Sign up to request clarification or add additional context in comments.

Comments

2

You should post online your mkmf.log file, but you also need to check if your Ruby and PostgreSQL are using the same OpenSSL version.

It could happen that you've installed Ruby and OpenSSL by RVM and your PostgreSQL is using the system's version. This will lead to conflict.

1 Comment

This worked for me. I had installed OpenSSL via linuxbrew and apt-get. Deleted my brew version and it worked. Thanks!
-1

I have the same issue on my PC. I just run rvm get stable for updating rvm and run one more time bundle install. After this pg gem was installed successfully.

1 Comment

still the same rvm -v : rvm 1.26.3 (latest) by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.io/]
-1

I guess you have Postgres installed correctly. Did you try to pass the archflags like this?

env ARCHFLAGS="-arch x86_64" gem install pg

1 Comment

Yes, I already tried that; its not working.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.