2

283

65 I'm trying to install PostgreSQL's pg gem for Ruby.

I issued the following command:

gem install pg
I installed Ruby 1.9.2 using RVM.

The above command shows me the following error.

The error is :

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.2-preview3/bin/ruby extconf.rb

checking for pg_config... yes
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.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 ***

etc...

Somebody gave solution for Ubuntu users. What about OpenSUSE Linux?

Thanks for advance.

2 Answers2

6

For me this was the solution:

zypper in postgresql-server-devel

pg_config is part of postgresql-server-devel, if you install that package then it should work on Tumbleweed at least.

Source: https://lists.opensuse.org/opensuse-factory/2019-03/msg00300.html

bonyiii
  • 2,833
  • 29
  • 25
0

As per my search OpenSUSE linux has no package for client of Postgres, but as you have installed that it, that mean chances are the file pgsql.so is present in your system. How did you install it, I can see following which says it will install development libraries and client also

sudo zypper in postgresql postgresql-server postgresql-contrib
sudo zypper in postgresql-plperl postgresql-plpython postgresql-plctl

If this does not work then try to search in postgres installation path this file, locate file_name is easy to find files on different linux, but not sure it works in openSUSE it is part of mlocate package. If you find that file then symbol link it as per error, where error is searching this file.

If it is still not working, then you can use your Postgres directory in environment variable and try to install gem individually. To get postgres configuration use following command to see directories.

pg_config

Now try to install gem

PATH=$PATH:/Library/PostgreSQL/9.0/bin sudo gem install pg

On some system following command also resolve issue, so you can try it too

sudo gem install pg – --with-pg-config=/usr/local/pgsql/bin/pg_config
Kamal Panhwar
  • 2,345
  • 3
  • 21
  • 37
  • Very useful. But I just will avoid complicate myself and work on Ubuntu based Linux environments. Thanks for your help. – user9142318 Jan 11 '20 at 04:23
  • I suggest just try it is not complicated just run two commands above and hopefully it will work, always try you will gain more knowledge doing so. good luck. – Kamal Panhwar Jan 11 '20 at 04:24