RoR latest and PostgreSQL 9.1.3

Hi every:
I’m trying to install postgres gem but since I have latest postgres
version then some problems appears. When I run gem install postgres I
get this:

[root@ruby-devserver 9.1]# gem install postgres
Building native extensions. This could take a while…
ERROR: Error installing postgres:
ERROR: Failed to build gem native extension.

     /usr/local/rvm/rubies/ruby-1.9.3-p125/bin/ruby extconf.rb

checking for pg_config… no
No pg_config… trying anyway. If building fails, please try again with
–with-pg-config=/path/to/pg_config
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.

Provided configuration options:
–with-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=/usr/local/rvm/rubies/ruby-1.9.3-p125/bin/ruby
–with-pg
–without-pg
–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-pg-config
–without-pg-config
–with-pg_config
–without-pg_config

Gem files will remain installed in
/usr/local/rvm/gems/ruby-1.9.3-p125/gems/pg-0.13.2 for inspection.
Results logged to
/usr/local/rvm/gems/ruby-1.9.3-p125/gems/pg-0.13.2/ext/gem_make.out

Then if I try to run this

[root@ruby-devserver 9.1]# gem install postgres
–with-pg-config=/var/lib/psql/9.1/data/[root@ruby-devserver data]# gem
install postgres --with-pg-config=/var/lib/psql/9.1/data/postgresql.conf
ERROR: While executing gem … (OptionParser::InvalidOption)
invalid option:
–with-pg-config=/var/lib/psql/9.1/data/postgresql.conf
[root@ruby-devserver data]# gem install postgres
–with-pg-config=/var/lib/psql/9.1/data/
ERROR: While executing gem … (OptionParser::InvalidOption)
invalid option: --with-pg-config=/var/lib/psql/9.1/data/

but whithout success, any help on this?

Regards

Ing. Reynier Perez M.
eMail: [email protected], [email protected]
Skype: reynierpm
Mobile: +58 424.180.5609
Site: http://reynierpm.site90.com

On Thu, Mar 1, 2012 at 2:27 PM, ReynierPM [email protected] wrote:

checking for pg_config… no
No pg_config… trying anyway. If building fails, please try again with
–with-pg-config=/path/to/pg_config
checking for libpq-fe.h… no
Can’t find the 'libpq-fe.h header

You probably miss the libpq-dev package.

Check this for reference:

http://rails.vandenabeele.com/blog/2011/11/26/installing-ruby-and-rails-with-rvm-on-ubuntu-11-dot-10/

If you still face problems, what is your exact version of Operating
System ?

HTH,

Peter

I don’t think so because I installed PostgreSQL using this guide[1] and
there -devel packages are installed. Anyway I’m using CentOS 6.2. I’ve
try to create a project and get SQLite problems the force postgresql as
database and get this errors:


run bundle install
Fetching source index for https://rubygems.org/
Using rake (0.9.2.2)
Using i18n (0.6.0)
Using multi_json (1.1.0)
Using activesupport (3.2.1)
Using builder (3.0.0)
Using activemodel (3.2.1)
Using erubis (2.7.0)
Using journey (1.0.3)
Using rack (1.4.1)
Using rack-cache (1.1)
Using rack-test (0.6.1)
Using hike (1.2.1)
Using tilt (1.3.3)
Using sprockets (2.1.2)
Using actionpack (3.2.1)
Using mime-types (1.17.2)
Using polyglot (0.3.3)
Using treetop (1.4.10)
Using mail (2.4.1)
Using actionmailer (3.2.1)
Using arel (3.0.2)
Using tzinfo (0.3.31)
Using activerecord (3.2.1)
Using activeresource (3.2.1)
Using bundler (1.0.22)
Using coffee-script-source (1.2.0)
Using execjs (1.3.0)
Using coffee-script (2.2.0)
Using rack-ssl (1.3.2)
Using json (1.6.5)
Using rdoc (3.12)
Using thor (0.14.6)
Using railties (3.2.1)
Using coffee-rails (3.2.2)
Using jquery-rails (2.0.1)
Installing pg (0.13.2) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native
extension.

     /usr/local/rvm/rubies/ruby-1.9.3-p125/bin/ruby extconf.rb

checking for pg_config… no
No pg_config… trying anyway. If building fails, please try again with
–with-pg-config=/path/to/pg_config
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.

Provided configuration options:
–with-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=/usr/local/rvm/rubies/ruby-1.9.3-p125/bin/ruby
–with-pg
–without-pg
–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-pg-config
–without-pg-config
–with-pg_config
–without-pg_config

Gem files will remain installed in
/usr/local/rvm/gems/ruby-1.9.3-p125/gems/pg-0.13.2 for inspection.
Results logged to
/usr/local/rvm/gems/ruby-1.9.3-p125/gems/pg-0.13.2/ext/gem_make.out
An error occured while installing pg (0.13.2), and Bundler cannot
continue.
Make sure that gem install pg -v '0.13.2' succeeds before bundling.

This is the correct gem? pg? Any other help on get RoR and PostgreSQL up
and running?

[1]
http://davidghedini.blogspot.com/2010/10/install-postgresql-9-on-centos.html
Ing. Reynier Perez M.
eMail: [email protected], [email protected]
Skype: reynierpm
Mobile: +58 424.180.5609
Site: http://reynierpm.site90.com

The problem is just one: doesn’t work even if I provide correct paths to
gem installer. See below:

[root@ruby-devserver yum.repos.d]# locate libpq-fe.h
/usr/pgsql-9.1/include/libpq-fe.h

So it’s installed!!! :smiley:

[root@ruby-devserver yum.repos.d]# gem install pg –
–with-pgsql-include-dir=/usr/psql-9.1/include
Building native extensions. This could take a while…
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.

     /usr/local/rvm/rubies/ruby-1.9.3-p125/bin/ruby extconf.rb

–with-pgsql-include-dir=/usr/psql-9.1/include
checking for pg_config… no
No pg_config… trying anyway. If building fails, please try again with
–with-pg-config=/path/to/pg_config
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.

Provided configuration options:
–with-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=/usr/local/rvm/rubies/ruby-1.9.3-p125/bin/ruby
–with-pg
–without-pg
–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-pg-config
–without-pg-config
–with-pg_config
–without-pg_config

Gem files will remain installed in
/usr/local/rvm/gems/ruby-1.9.3-p125/gems/pg-0.13.2 for inspection.
Results logged to
/usr/local/rvm/gems/ruby-1.9.3-p125/gems/pg-0.13.2/ext/gem_make.out

:frowning: any help?

Ing. Reynier Perez M.
eMail: [email protected], [email protected]
Skype: reynierpm
Mobile: +58 424.180.5609
Site: http://reynierpm.site90.com

On Thu, Mar 1, 2012 at 10:54 AM, ReynierPM [email protected] wrote:

The problem is just one: doesn’t work even if I provide correct paths to gem
installer. See below:

checking for pg_config… no
No pg_config… trying anyway. If building fails, please try again with
–with-pg-config=/path/to/pg_config

So, it fails; where is pg_config, and have you followed the directive
to try building with that path?


Hassan S. ------------------------ [email protected]

twitter: @hassan

On Thu, Mar 1, 2012 at 9:31 AM, ReynierPM [email protected] wrote:

Installing pg (0.13.2) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native
extension.

/usr/local/rvm/rubies/ruby-1.9.3-p125/bin/ruby extconf.rb
checking for pg_config… no
No pg_config… trying anyway. If building fails, please try again with
–with-pg-config=/path/to/pg_config
checking for libpq-fe.h… no
Can’t find the 'libpq-fe.h header

So what’s unclear about that? If you believe the required files are
on your system, find them and provide the correct path to the gem
installer. And if they’re not, install them :slight_smile:


Hassan S. ------------------------ [email protected]

twitter: @hassan

On Thu, Mar 1, 2012 at 3:35 PM, ReynierPM [email protected] wrote:

Ok, I try again with this line and see the results:

[root@ruby-devserver ~]# gem install pg
–with-pg-include=/usr/pgsql-9.1/include/
–with-pg-config=/var/lib/pgsql/9.1/data/

ERROR: While executing gem … (OptionParser::InvalidOption)
invalid option: --with-pg-include=/usr/pgsql-9.1/include/

This time you left off the additional ‘–’ after gem install pg - you
had
it in there the time before. It tells gem the following flags are for
the
specific gem you’re installing, not for the gem command itself.


Hassan S. ------------------------ [email protected]

twitter: @hassan

Ok but can you tell me which is the correct line? I’m lost here :frowning:

Ing. Reynier Perez M.
eMail: [email protected], [email protected]
Skype: reynierpm
Mobile: +58 424.180.5609
Site: http://reynierpm.site90.com

Ok, I try again with this line and see the results:

[root@ruby-devserver ~]# gem install pg
–with-pg-include=/usr/pgsql-9.1/include/
–with-pg-config=/var/lib/pgsql/9.1/data/
ERROR: While executing gem … (OptionParser::InvalidOption)
invalid option: --with-pg-include=/usr/pgsql-9.1/include/

===========================
[root@ruby-devserver ~]# locate libpq-fe.h
/usr/pgsql-9.1/include/libpq-fe.h

[root@ruby-devserver ~]# ll /var/lib/pgsql/9.1/data/
total 92
drwx------ 5 postgres postgres 4096 Mar 1 08:46 base
drwx------ 2 postgres postgres 4096 Mar 1 18:42 global
drwx------ 2 postgres postgres 4096 Mar 1 08:46 pg_clog
-rw------- 1 postgres postgres 4266 Mar 1 12:42 pg_hba.conf
-rw------- 1 postgres postgres 1636 Mar 1 08:46 pg_ident.conf
drwx------ 2 postgres postgres 4096 Mar 1 08:47 pg_log
drwx------ 4 postgres postgres 4096 Mar 1 08:46 pg_multixact
drwx------ 2 postgres postgres 4096 Mar 1 18:41 pg_notify
drwx------ 2 postgres postgres 4096 Mar 1 08:46 pg_serial
drwx------ 2 postgres postgres 4096 Mar 1 19:04 pg_stat_tmp
drwx------ 2 postgres postgres 4096 Mar 1 08:46 pg_subtrans
drwx------ 2 postgres postgres 4096 Mar 1 08:46 pg_tblspc
drwx------ 2 postgres postgres 4096 Mar 1 08:46 pg_twophase
-rw------- 1 postgres postgres 4 Mar 1 08:46 PG_VERSION
drwx------ 3 postgres postgres 4096 Mar 1 08:46 pg_xlog
-rw------- 1 postgres postgres 19137 Mar 1 10:15 postgresql.conf
-rw------- 1 postgres postgres 71 Mar 1 18:41 postmaster.opts
-rw------- 1 postgres postgres 72 Mar 1 18:41 postmaster.pid

So what I’m doing wrong?

Ing. Reynier Perez M.
eMail: [email protected], [email protected]
Skype: reynierpm
Mobile: +58 424.180.5609
Site: http://reynierpm.site90.com

On Thursday, March 1, 2012 9:14:35 PM UTC-3, Reynier Prez Mira wrote:

Ok but can you tell me which is the correct line? I’m lost here :frowning:

gem install pg – --with-pg-include=… --with-pg-lib=…

Note the double dashes…

Looking at “gem help install” would have helped you.


Luis L.

Ok, I fix the double dashes but now see the output:

[root@ruby-devserver ~]# gem install pg –
–with-pg-include=/usr/pgsql-9.1/include/
–with-pg-config=/var/lib/pgsql/9.1/data/
Building native extensions. This could take a while…
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.

     /usr/local/rvm/rubies/ruby-1.9.3-p125/bin/ruby extconf.rb

–with-pg-include=/usr/pgsql-9.1/include/
–with-pg-config=/var/lib/pgsql/9.1/data/
Using config values from /var/lib/pgsql/9.1/data/
sh: /var/lib/pgsql/9.1/data/: is a directory
sh: /var/lib/pgsql/9.1/data/: is a directory
checking for libpq-fe.h… *** 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
–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=/usr/local/rvm/rubies/ruby-1.9.3-p125/bin/ruby
–with-pg
–without-pg
–with-pg-dir
–without-pg-dir
–with-pg-include=${pg-dir}/include
–with-pg-lib
–without-pg-lib=${pg-dir}/lib
–with-pg-config
/usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:381:in
try_do': The compiler failed to generate an executable file. (RuntimeError) You have to install development tools first. from /usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:506:in try_cpp’
from
/usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:970:in
block in find_header' from /usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:790:in block in checking_for’
from
/usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:284:in
block (2 levels) in postpone' from /usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:254:in open’
from
/usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:284:in
block in postpone' from /usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:254:in open’
from
/usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:280:in
postpone' from /usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:789:in checking_for’
from
/usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:969:in
find_header' from extconf.rb:40:in

Gem files will remain installed in
/usr/local/rvm/gems/ruby-1.9.3-p125/gems/pg-0.13.2 for inspection.
Results logged to
/usr/local/rvm/gems/ruby-1.9.3-p125/gems/pg-0.13.2/ext/gem_make.out

I notice this “You have to install development tools first.” which DT is
needed here?

Ing. Reynier Perez M.
eMail: [email protected], [email protected]
Skype: reynierpm
Mobile: +58 424.180.5609
Site: http://reynierpm.site90.com

On Thu, Mar 1, 2012 at 4:35 PM, ReynierPM [email protected] wrote:

Ok, I fix the double dashes but now see the output:

[root@ruby-devserver ~]# gem install pg –
–with-pg-include=/usr/pgsql-9.1/include/
–with-pg-config=/var/lib/pgsql/9.1/data/

which looks nothing like the working example I gave you. Please
go back and read my last message.


Hassan S. ------------------------ [email protected]

twitter: @hassan

Ok, I go one step before and run the command as you and see the result:

[root@ruby-devserver ~]# gem install pg –
–with-pg-config=/var/lib/pgsql/9.1/data/
Building native extensions. This could take a while…
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.

     /usr/local/rvm/rubies/ruby-1.9.3-p125/bin/ruby extconf.rb

–with-pg-config=/var/lib/pgsql/9.1/data/
Using config values from /var/lib/pgsql/9.1/data/
sh: /var/lib/pgsql/9.1/data/: is a directory
sh: /var/lib/pgsql/9.1/data/: is a directory
checking for libpq-fe.h… *** 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
–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=/usr/local/rvm/rubies/ruby-1.9.3-p125/bin/ruby
–with-pg
–without-pg
–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-pg-config
/usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:381:in
try_do': The compiler failed to generate an executable file. (RuntimeError) You have to install development tools first. from /usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:506:in try_cpp’
from
/usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:970:in
block in find_header' from /usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:790:in block in checking_for’
from
/usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:284:in
block (2 levels) in postpone' from /usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:254:in open’
from
/usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:284:in
block in postpone' from /usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:254:in open’
from
/usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:280:in
postpone' from /usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:789:in checking_for’
from
/usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:969:in
find_header' from extconf.rb:40:in

Gem files will remain installed in
/usr/local/rvm/gems/ruby-1.9.3-p125/gems/pg-0.13.2 for inspection.
Results logged to
/usr/local/rvm/gems/ruby-1.9.3-p125/gems/pg-0.13.2/ext/gem_make.out

Ing. Reynier Perez M.
eMail: [email protected], [email protected]
Skype: reynierpm
Mobile: +58 424.180.5609
Site: http://reynierpm.site90.com

On Thu, Mar 1, 2012 at 4:14 PM, ReynierPM [email protected] wrote:

Ok but can you tell me which is the correct line? I’m lost here :frowning:

Just go one step at a time. Here’s exactly what works on my Mac:

gem install pg –
–with-pg-config=/opt/local/lib/postgresql84/bin/pg_config

You should be able to just substitute the appropriate location for
your own pg_config file.


Hassan S. ------------------------ [email protected]

twitter: @hassan

Ok, sorry I found the directory in another place so all the time I was
wrong thinking in config files and because of that I use
/var/lib/pgsql/9.1/data and not /usr/pgsql-9.1/bin/pg_config as should
be from the beginning. So aplogies once more time :frowning:

Ing. Reynier Perez M.
eMail: [email protected], [email protected]
Skype: reynierpm
Mobile: +58 424.180.5609
Site: http://reynierpm.site90.com

On Mar 1, 2012, at 10:50 AM, Hassan S. wrote:

So what’s unclear about that? If you believe the required files are
on your system, find them and provide the correct path to the gem
installer. And if they’re not, install them :slight_smile:

What’s unclear about it is that it doesn’t fucking work.

Been there, done that, the error message and instructions are incorrect;
providing the path to pg_config does not work, even when the postgres
install is completely default with everything in the standard location.
It’s a bit frustrating that I can’t find my notes right now, but
basically nearly all the results from google searches are really bad
advice, and what is required is to use the option that specifies the
root of the postgres install.


Scott R.
[email protected]
http://www.elevated-dev.com/
(303) 722-0567 voice

On Thu, Mar 1, 2012 at 5:02 PM, ReynierPM [email protected] wrote:

Ok, I go one step before and run the command as you and see the result:

[root@ruby-devserver ~]# gem install pg –
–with-pg-config=/var/lib/pgsql/9.1/data/

Does that path end with a file named ‘pg_config’? No. It does not.
So, again, nothing like the example I gave you.


Hassan S. ------------------------ [email protected]

twitter: @hassan

On Sat, Mar 3, 2012 at 4:53 AM, Scott R. [email protected]
wrote:

On Mar 1, 2012, at 10:50 AM, Hassan S. wrote:

So what’s unclear about that? If you believe the required files are
on your system, find them and provide the correct path to the gem
installer. And if they’re not, install them :slight_smile:

What’s unclear about it is that it doesn’t work.

Been there, done that, the error message and instructions are incorrect;
providing the path to pg_config does not work, even when the postgres install is
completely default with everything in the standard location. It’s a bit
frustrating that I can’t find my notes right now, but basically nearly all the
results from google searches are really bad advice, and what is required is to use
the option that specifies the root of the postgres install.

If there is a reproduceable bug in core Postgres, please show me here
so I can resolve it.


Simon R. http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services