RoR latest and PostgreSQL 9.1.3

201 views
Skip to first unread message

ReynierPM

unread,
Mar 1, 2012, 8:27:16 AM3/1/12
to rubyonra...@googlegroups.com
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 Mira
eMail: reyn...@gmail.com, reyn...@hotmail.com
Skype: reynierpm
Mobile: +58 424.180.5609
Site: http://reynierpm.site90.com

Peter Vandenabeele

unread,
Mar 1, 2012, 10:30:21 AM3/1/12
to rubyonra...@googlegroups.com
On Thu, Mar 1, 2012 at 2:27 PM, ReynierPM <reyn...@gmail.com> wrote:
> 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

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

ReynierPM

unread,
Mar 1, 2012, 12:31:52 PM3/1/12
to rubyonra...@googlegroups.com
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

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 Mira
eMail: reyn...@gmail.com, reyn...@hotmail.com
Skype: reynierpm
Mobile: +58 424.180.5609
Site: http://reynierpm.site90.com

Hassan Schroeder

unread,
Mar 1, 2012, 12:50:36 PM3/1/12
to rubyonra...@googlegroups.com
On Thu, Mar 1, 2012 at 9:31 AM, ReynierPM <reyn...@gmail.com> 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 :-)

--
Hassan Schroeder ------------------------ hassan.s...@gmail.com
http://about.me/hassanschroeder
twitter: @hassan

ReynierPM

unread,
Mar 1, 2012, 1:54:31 PM3/1/12
to rubyonra...@googlegroups.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!!! :D

[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

:( any help?

Ing. Reynier Perez Mira
eMail: reyn...@gmail.com, reyn...@hotmail.com
Skype: reynierpm
Mobile: +58 424.180.5609
Site: http://reynierpm.site90.com

Hassan Schroeder

unread,
Mar 1, 2012, 5:47:36 PM3/1/12
to rubyonra...@googlegroups.com
On Thu, Mar 1, 2012 at 10:54 AM, ReynierPM <reyn...@gmail.com> 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?

ReynierPM

unread,
Mar 1, 2012, 6:35:04 PM3/1/12
to rubyonra...@googlegroups.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 Mira
eMail: reyn...@gmail.com, reyn...@hotmail.com
Skype: reynierpm
Mobile: +58 424.180.5609
Site: http://reynierpm.site90.com

Hassan Schroeder

unread,
Mar 1, 2012, 7:01:52 PM3/1/12
to rubyonra...@googlegroups.com
On Thu, Mar 1, 2012 at 3:35 PM, ReynierPM <reyn...@gmail.com> 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.

ReynierPM

unread,
Mar 1, 2012, 7:14:35 PM3/1/12
to rubyonra...@googlegroups.com
Ok but can you tell me which is the correct line? I'm lost here :(

Ing. Reynier Perez Mira
eMail: reyn...@gmail.com, reyn...@hotmail.com
Skype: reynierpm
Mobile: +58 424.180.5609
Site: http://reynierpm.site90.com

Hassan Schroeder

unread,
Mar 1, 2012, 7:24:01 PM3/1/12
to rubyonra...@googlegroups.com
On Thu, Mar 1, 2012 at 4:14 PM, ReynierPM <reyn...@gmail.com> wrote:
> Ok but can you tell me which is the correct line? I'm lost here :(

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.

Luis Lavena

unread,
Mar 1, 2012, 7:25:41 PM3/1/12
to rubyonra...@googlegroups.com
On Thursday, March 1, 2012 9:14:35 PM UTC-3, Reynier Pérez Mira wrote:
Ok but can you tell me which is the correct line? I'm lost here :(


gem install pg -- --with-pg-include=... --with-pg-lib=...

Note the double dashes...

Looking at "gem help install" would have helped you.

--
Luis Lavena
 

ReynierPM

unread,
Mar 1, 2012, 7:35:00 PM3/1/12
to rubyonra...@googlegroups.com
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 `<main>'


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 Mira
eMail: reyn...@gmail.com, reyn...@hotmail.com
Skype: reynierpm
Mobile: +58 424.180.5609
Site: http://reynierpm.site90.com

Hassan Schroeder

unread,
Mar 1, 2012, 7:53:19 PM3/1/12
to rubyonra...@googlegroups.com
On Thu, Mar 1, 2012 at 4:35 PM, ReynierPM <reyn...@gmail.com> 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.

ReynierPM

unread,
Mar 1, 2012, 8:02:41 PM3/1/12
to rubyonra...@googlegroups.com
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

Ing. Reynier Perez Mira

Hassan Schroeder

unread,
Mar 1, 2012, 8:53:05 PM3/1/12
to rubyonra...@googlegroups.com
On Thu, Mar 1, 2012 at 5:02 PM, ReynierPM <reyn...@gmail.com> 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.

ReynierPM

unread,
Mar 1, 2012, 9:13:40 PM3/1/12
to rubyonra...@googlegroups.com
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 :-(

Ing. Reynier Perez Mira
eMail: reyn...@gmail.com, reyn...@hotmail.com
Skype: reynierpm
Mobile: +58 424.180.5609
Site: http://reynierpm.site90.com

Scott Ribe

unread,
Mar 2, 2012, 11:53:43 PM3/2/12
to rubyonra...@googlegroups.com, Hassan Schroeder
On Mar 1, 2012, at 10:50 AM, Hassan Schroeder 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 :-)

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 Ribe
scott...@elevated-dev.com
http://www.elevated-dev.com/
(303) 722-0567 voice


Simon Riggs

unread,
Mar 3, 2012, 3:25:13 AM3/3/12
to rubyonra...@googlegroups.com
On Sat, Mar 3, 2012 at 4:53 AM, Scott Ribe <scott...@elevated-dev.com> wrote:
> On Mar 1, 2012, at 10:50 AM, Hassan Schroeder 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 :-)
>
> 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 Riggs                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

Reply all
Reply to author
Forward
0 new messages