2

Centos 6.9 (similar to question: Can't find the PostgreSQL client library (libpq) but that one is on MacOS not Centos, so those solutions did not work

ruby 2.1.8 (tried 2.2)

rails 4.2.6 (tried 5.0)

postgres 9.3

I am trying to install the pg gem with:

gem install pg -- --with-pqlib=/usr/lib64/libpqxx-4.0.so --with-pg-config=/usr/pgsql-9.3/bin/pg_config

I keep trying to feed it different libraries but the one it is getting stuck on is some PQconnectdb() function. Error below

Rails used to be installed on this computer with pg but something happend after an update.. Any ideas here?

ERROR:  Error installing pg:
ERROR: Failed to build gem native extension.

current directory: /home/myusername/.rvm/gems/ruby-2.1.8/gems/pg-0.14.1/ext
/home/myusername/.rvm/rubies/ruby-2.1.8/bin/ruby -r ./siteconf20170425-12873-191077o.rb extconf.rb --with-pqlib=/usr/lib64/libpqxx-4.0.so --with-pg-config=/usr/pgsql-9.3/bin/pg_config
Using config values from /usr/pgsql-9.3/bin/pg_config
extconf.rb:34: warning: Insecure world writable dir /opt/anaconda in PATH, mode 040777
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -l/usr/lib64/libpqxx-4.0.so... 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.

Installed pg libraries:Installed Packages postgresql93.x86_64 9.3.16-1PGDG.rhel6
postgresql93-contrib.x86_64 9.3.16-1PGDG.rhel6
postgresql93-debuginfo.x86_64 9.3.16-1PGDG.rhel6
postgresql93-devel.x86_64 9.3.16-1PGDG.rhel6
postgresql93-docs.x86_64 9.3.16-1PGDG.rhel6
postgresql93-libs.x86_64 9.3.16-1PGDG.rhel6
postgresql93-odbc.x86_64 09.06.0100-1PGDG.rhel6
postgresql93-odbc-debuginfo.x86_64 09.03.0400-1PGDG.rhel6
postgresql93-plperl.x86_64 9.3.16-1PGDG.rhel6
postgresql93-plpython.x86_64 9.3.16-1PGDG.rhel6
postgresql93-pltcl.x86_64 9.3.16-1PGDG.rhel6
postgresql93-server.x86_64 9.3.16-1PGDG.rhel6
postgresql93-tcl.x86_64 2.1.1-1.rhel6
postgresql93-tcl-debuginfo.x86_64 2.1.1-1.rhel6
postgresql93-test.x86_64 9.3.16-1PGDG.rhel6

Community
  • 1
  • 1
GavinBelson
  • 2,514
  • 25
  • 36

2 Answers2

1

Have you tried this?

$ sudo su
$ env ARCHFLAGS="-arch x86_64" gem install pg
mahatmanich
  • 10,791
  • 5
  • 63
  • 82
  • Yeah, that one throw a `checking for libpq-fe.h... *** extconf.rb failed ***` error, even if I use: `--with-pg-config=/usr/pgsql-9.3/bin/pg_config` – GavinBelson Apr 25 '17 at 15:13
1

I had a linux brew package manager, which had some old dependencies that messed with the pg gem install.

The answer is:

  • Remove [linux brew][1]

    [1]: http://linuxbrew.sh/

  • Uninstall Ruby With RVM
  • Implode RVM
  • Reinstall RVM
  • Reinstall ruby
  • Install pg gem with a pg config option:

gem install pg -- --with-pg-config=/usr/pgsql-9.3/bin/pg_config

GavinBelson
  • 2,514
  • 25
  • 36