pg_config, ruby pg, postgresql 9.0 problem after upgrade, centos 5

14,322

Solution 1

There are various config options you can add to the gem install, like -with-opt-dir, --with-pg-dir and --with-pg-config. Look at this mailing list thread:

http://www.ruby-forum.com/topic/409608

Solution 2

$ gem --version
1.3.7

$ ruby --version
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux]

$ cat /etc/redhat-release 
CentOS release 5.4 (Final)

$ uname -m
x86_64

sudo yum list installed | grep postgre    (see what you have installed)
sudo yum list available | grep postgre    (I was missing postgresql-devel)
sudo yum install postgresql-devel         (I installed it)
sudo gem install pg                       (no error this time!)

$ gem list --local | grep pg
pg (0.11.0)

Solution 3

This seems like a pg config file location error,

gem install pg -- --with-pgsql-lib=/usr/pgsql-9.0/lib --with-pg-config=/usr/pgsql-9.1/bin/pg_config

solves it!!

gem install pg -- --with-pgsql-lib=/usr/pgsql-9.0/lib --with-pg-config=/usr/pgsql-9.1/bin/pg_config

/usr/local/lib/ruby/1.9.1/yaml.rb:56:in `<top (required)>':
It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.
Building native extensions.  This could take a while...
Successfully installed pg-0.14.0
1 gem installed
Installing ri documentation for pg-0.14.0...
Installing RDoc documentation for pg-0.14.0...

Solution 4

On Mac OSX 10.6.8, using the MacPorts install of Postgres 9, the following command worked for me:

gem install pg -- --with-pgsql-lib=/opt/local/lib/postgresql90/lib --with-pg-config=/opt/local/lib/postgresql90/bin/pg_config
Share:
14,322
objah
Author by

objah

Updated on June 16, 2022

Comments

  • objah
    objah almost 2 years

    After upgrade postgresql 8.1 to 9.0 ive noticed issues with libraries dependency. Postgresql works fine (connection, queries).

    yum list postgresql*
    Installed Packages
    postgresql.i386 9.0.0-1PGDG.el5 installed
    postgresql-debuginfo.i386 9.0.0-1PGDG.el5 installed
    postgresql-devel.i386 9.0.0-1PGDG.el5 installed
    postgresql-libs.i386 9.0.0-1PGDG.el5 installed
    postgresql-odbcng.i386 0.90.101-2.el5 installed
    postgresql-plruby.i386 0.5.1-5.el5 installed
    postgresql-server.i386 9.0.0-1PGDG.el5 install
    

    but when im trying to install 'pg' for ruby, ive received

    gem install pg
    Building native extensions.  This could take a while...
    ERROR:  Error installing pg:
            ERROR: Failed to build gem native extension.
    
    /usr/local/bin/ruby extconf.rb
    checking for pg_config... no
    checking for libpq-fe.h... no
    Can't find the 'libpq-fe.h header
    *** 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.
    

    When trying with another ruby-postgres driver, ive got

    yum install ruby-postgres
    ruby-postgres-0.7.1-5.el5.i386 from epel has depsolving problems
      --> Missing Dependency: libpq.so.4 is needed by package ruby-postgres-0.7.1-5.el5.i386 (epel)
    

    and

    locate libpq.so.4
    /usr/lib/libpq.so.4
    /usr/lib/libpq.so.4.1
    

    also exported path

    LD_LIBRARY_PATH=/usr/pgsql-9.0/lib
    export LD_LIBRARY_PATH
    

    after running ruby script with "require pg" (works on 8.1), ive got:

    /usr/local/lib/ruby/site_ruby/1.8/i686-linux/pg_ext.so: libpq.so.4: cannot open shared object file: No such file or directory - /usr/local/lib/ruby/site_ruby/1.8/i686-linux/pg_ext.so (LoadError)
            from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in `require'
            from /usr/local/lib/ruby/site_ruby/1.8/pg.rb:12
            from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in `gem_original_require'
            from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in `require'
    

    Any suggestions what to do more?

  • objah
    objah over 13 years
    gem install pg -- --with-pgsql-lib=/usr/pgsql-9.0/lib --with-pg-config=/usr/pgsql-9.0/bin/pg_config , it solves pg installation, thank You! But still after runinng scripts ive got missing libpq.so.4...
  • Michael Kohl
    Michael Kohl over 13 years
    Any progress on this? Maybe update your question so we'll be better able to help you?
  • Albrino Fernando
    Albrino Fernando about 12 years
    I had the same scenario while trying to install pg gem on CentOS with pre-existing postgres installation. I suspect the problem is that pg_config could not be located, since I did not have it at all on my system. After installing postgresql-devel a pg_config was added and pg gem installed successfully.
  • Ramfjord
    Ramfjord about 9 years
    you probably meant for those pgsql-9.X versions to match up