Trying to install postgres gem on fedora 12

I get these errors :

gem install pg – --with-pgsql-include-dir=’/usr/include/pgsql’ –
with-pgsql-lib-dir=’/usr/lib/pgsql’
Building native extensions. This could take a while…
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.

/usr/bin/ruby extconf.rb --with-pgsql-include-dir=/usr/include/pgsql –
with-pgsql-lib-dir=/usr/lib/pgsql
can’t find header files for ruby.

Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/
pg-0.9.0 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/pg-0.9.0/ext/
gem_make.out

from yum list postgres*, the relevant stuff I have installed is:

Installed Packages
postgresql.i686
8.4.2-1.fc12 @updates
postgresql-devel.i686
8.4.2-1.fc12 @updates
postgresql-libs.i686
8.4.2-1.fc12 @updates
postgresql-server.i686
8.4.2-1.fc12 @updates

I tried to run this with the debuger:
ruby -r debug extconf.rb --with-pgsql-include-dir=/usr/include/pgsql –
with-pgsql-lib-dir=/usr/lib/pgsql

this block of code in /usr/lib/ruby/1.8/mkmf.rb is where the error
happens

topdir = File.dirname(libdir = File.dirname(FILE))
extdir = File.expand_path(“ext”, topdir)
$extmk = File.expand_path($0)[0, extdir.size+1] == extdir+"/"
if not $extmk and File.exist?(Config::CONFIG[“archdir”] + “/ruby.h”)
$hdrdir = $topdir = Config::CONFIG[“archdir”]
elsif File.exist?(($top_srcdir ||= topdir) + “/ruby.h”) and
File.exist?(($topdir ||= Config::CONFIG[“topdir”]) + “/config.h”)
$hdrdir = $top_srcdir
else
abort “can’t find header files for ruby.”
end

it’s looking for ruby.h in either:
/usr/lib/ruby/1.8/i386-linux
/usr/lib/ruby/

and config.h in
/usr/lib/ruby/1.8/i386-linux

but those files are not there …

so I did:

yum install ruby-devel.i686

now I get: can’t find libpq-fe.h.

gem install pg – --with-pgsql-include-dir=/usr/include/pgsql --with-
pgsql-lib-dir=/usr/lib/pgsql
Building native extensions. This could take a while…
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.

/usr/bin/ruby extconf.rb --with-pgsql-include-dir=/usr/include/pgsql –
with-pgsql-lib-dir=/usr/lib/pgsql
checking for pg_config… yes
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
–without-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/bin/ruby
–with-pg
–without-pg
–with-pg-config
–without-pg-config
–with-pg-dir
–without-pg-dir
–with-pg-include
–without-pg-include=${pg-dir}/include
–with-pg-lib
–without-pg-lib=${pg-dir}/lib
–enable-static-build
–disable-static-build

Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/
pg-0.9.0 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/pg-0.9.0/ext/
gem_make.out

On Thu, 2010-03-11 at 08:33 -0800, Jedrin wrote:

so I did:

yum install ruby-devel.i686

now I get: can’t find libpq-fe.h.


try

yum install postgresql-devel

Craig


This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

try

yum install postgresql-devel

I allready have that:

yum install postgresql-devel
Loaded plugins: presto, refresh-packagekit
Setting up Install Process
Package postgresql-devel-8.4.2-1.fc12.i686 already installed and
latest version
Nothing to do

The file is here: /usr/include/libpq-fe.h

but this doesn’t work:

gem install pg – --with-pgsql-include-dir=/usr/include
Building native extensions. This could take a while…
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.

/usr/bin/ruby extconf.rb --with-pgsql-include-dir=/usr/include
checking for pg_config… yes
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
–without-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/bin/ruby
–with-pg
–without-pg
–with-pg-config
–without-pg-config
–with-pg-dir
–without-pg-dir
–with-pg-include
–without-pg-include=${pg-dir}/include
–with-pg-lib
–without-pg-lib=${pg-dir}/lib
–enable-static-build
–disable-static-build

Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/
pg-0.9.0 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/pg-0.9.0/ext/
gem_make.out
[[email protected] ext]#

On Thu, 2010-03-11 at 09:11 -0800, Jedrin wrote:

I don’t know if that means I have something wrong or incompatible on
my system or if I should just try copying the file into the directory
with the other ones


don’t manually ‘fix’ things - that would destroy the whole reason for
packaging.

If /usr/include/libpq-fe.h actually exists, the compiler doesn’t believe
it.

Try removing and re-installing the postgresql-devel package

yum remove postgresql-devel
yum install postgresql-devel

Craig


This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

so I have these files in one place:

/usr/include/pgsql/internal/libpq-int.h
/usr/include/pgsql/server/libpq/libpq-be.h
/usr/include/pgsql/server/libpq/libpq.h
/usr/include/pgsql/server/libpq/libpq-fs.h

and then I have this file here:
/usr/include/libpq-fe.h

I don’t know if that means I have something wrong or incompatible on
my system or if I should just try copying the file into the directory
with the other ones

Try removing and re-installing the postgresql-devel package

yum remove postgresql-devel
yum install postgresql-devel

Ok, I just did that, but I am having a problem that my gem command is
not working all of a sudden.
I had also tried to debug the extconf.rb, I had stepped inside a
function that appeared to hang so I killed the process.

gem --help
/usr/lib/ruby/site_ruby/1.8/rubygems.rb:521:in expand_path': No such file or directory - getcwd (Errno::ENOENT) from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:521:infind_files’
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:520:in map' from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:520:infind_files’
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:1132
from /usr/bin/gem:8:in `require’
from /usr/bin/gem:8

On Thu, 2010-03-11 at 09:48 -0800, Jedrin wrote:

gem --help
/usr/lib/ruby/site_ruby/1.8/rubygems.rb:521:in expand_path': No such file or directory - getcwd (Errno::ENOENT) from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:521:infind_files’
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:520:in map' from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:520:infind_files’
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:1132
from /usr/bin/gem:8:in `require’
from /usr/bin/gem:8


getcwd failure seems to indicate that your current path is a directory
that no longer exists (like it was deleted)

cd /

then try again

Craig


This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

(rdb:1) list
[683, 692] in /usr/lib/ruby/1.8/mkmf.rb
683 #
684 # For example, if have_header(‘foo.h’) returned true, then the
HAVE_FOO_H
In trying to debug this, I am not sure if setting a breakpoint inside
of a block and not reaching it means that code never executed or could
it be peculiar to blocks in ruby. I feel like I want to edit the ruby
core stuff and put debug ‘puts()’ call in it to figure out what is
happening …

685 # preprocessor macro would be passed to the compiler.
686 #
687 def have_header(header, &b)
=> 688 checking_for header do
689 if try_cpp(cpp_include(header), &b)
690 $defs.push(format("-DHAVE_%s", header.tr(“a-z./\055”, “A-
Z___”)))
691 true
692 else
(rdb:1) break 689
Set breakpoint 2 at /usr/lib/ruby/1.8/mkmf.rb:689
(rdb:1) c
checking for libpq-fe.h… no
Can’t find the 'libpq-fe.h header
*** extconf.rb failed ***


getcwd failure seems to indicate that your current path is a directory
that no longer exists (like it was deleted)

cd /

then try again

That was strange as ‘ls’ showed I was in a directory, but that fixed
that problem, but after the reinstall I still have the same problem:

also, the extra args don’t allways seemed to matter as I get the same
error for
just “gem install pg” without the other args

gem install pg – --with-pgsql-include-dir=/usr/include/pgsql --with-
pgsql-lib-dir=/usr/lib/pgsql
Building native extensions. This could take a while…
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.

/usr/bin/ruby extconf.rb --with-pgsql-include-dir=/usr/include/pgsql –
with-pgsql-lib-dir=/usr/lib/pgsql
checking for pg_config… yes
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
–without-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/bin/ruby
–with-pg
–without-pg
–with-pg-config
–without-pg-config
–with-pg-dir
–without-pg-dir
–with-pg-include
–without-pg-include=${pg-dir}/include
–with-pg-lib
–without-pg-lib=${pg-dir}/lib
–enable-static-build
–disable-static-build

Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/
pg-0.9.0 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/pg-0.9.0/ext/
gem_make.out
[[email protected] /]#

On Thu, 2010-03-11 at 10:44 -0800, Jedrin wrote:

that problem, but after the reinstall I still have the same problem:

Provided configuration options:
–ruby=/usr/bin/ruby
–enable-static-build
–disable-static-build

Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/
pg-0.9.0 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/pg-0.9.0/ext/
gem_make.out
[[email protected] /]#


there should be no need to pass any extra parameters to the process in
order for it to build… I never needed to when I built the pg gem.
Perhaps there are other libraries missing but in theory, I would expect
that all you really need are postgresql-devel and ruby-devel libraries.

suggest that you start from scratch…

rm -fr /usr/lib/ruby/gems/1.8/gems/pg-0.9.0
gem install pg

and see what happens… then if it still fails, why not post the
relevant content of the
‘log’ /usr/lib/gems/1.8/gems/pg-0.9.0/ext/gem_make.out to the list?

Craig


This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

I had put debug prints in the code and the reopen of stdout messed
that up. In reality it tries the gcc command below. I did not have gcc
installed, I then installed that. When I try the gcc command line from
the log I get the error below, except I don’t know what directory ruby
issues that from:

gcc -E -I. -I/usr/lib/ruby/1.8/i386-linux -I. -D_FILE_OFFSET_BITS=64 -
I/usr/include -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -
fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -
mtune=atom -fasynchronous-unwind-tables -fno-strict-aliasing -fPIC
conftest.c -o conftest.i
gcc: conftest.c: No such file or directory

My code is dying someplace in a log file operation in mkmf.rb while
trying to find and process the header file:

module Logging
@log = nil
@logfile = ‘mkmf.log’
@orgerr = $stderr.dup
@orgout = $stdout.dup
@postpone = 0

def self::open
@log ||= File::open(@logfile, ‘w’)
@log.sync = true
$stderr.reopen(@log)
$stdout.reopen(@log) # <-- execution dies here
yield
ensure
$stderr.reopen(@orgerr)
$stdout.reopen(@orgout)
end

On Thu, 2010-03-11 at 12:28 -0800, Jedrin wrote:

#<File:mkmf.log>
no
–without-opt-include=${opt-dir}/include
–without-pg-config
–with-pg-dir
–without-pg-dir
–with-pg-include
–without-pg-include=${pg-dir}/include
–with-pg-lib
–without-pg-lib=${pg-dir}/lib
–enable-static-build
–disable-static-build
[[email protected] ~]#


I don’t know if this will make you feel better or worse but on my f12
setup, it just installed no problemo…

gem install pg

Building native extensions. This could take a while…
Successfully installed pg-0.9.0
1 gem installed
Installing ri documentation for pg-0.9.0…
Installing RDoc documentation for pg-0.9.0…

I’m wondering, do you have the gcc/build stuff installed? I’m asking
because this appears to be c and not a ruby build.

try yum install gcc-c++ autoconf make # that should probably be enough

Craig


This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

I deleted the directory as you mentioned and reran it. I have some of
my debug print code in the make file utility here in that log file as
well:

/usr/bin/ruby extconf.rb
checking for pg_config… my in check_for
my postpone:mkmftmp1.log
my open:mkmf.log
step 2
step 3
#<File:mkmf.log>
#IO:0xb78d6f64
yes
my check for header
checking for libpq-fe.h… my in check_for
my postpone:mkmftmp1.log
my open:mkmf.log
step 2
step 3
#<File:mkmf.log>
#IO:0xb78d6f64
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
–without-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/bin/ruby
–with-pg
–without-pg
–with-pg-config
–without-pg-config
–with-pg-dir
–without-pg-dir
–with-pg-include
–without-pg-include=${pg-dir}/include
–with-pg-lib
–without-pg-lib=${pg-dir}/lib
–enable-static-build
–disable-static-build
[[email protected] ~]#

ok, it seems to have worked. Thanks alot for your help …

I tried to be carefull, but I realize that the way ruby functions
return default values that debug code in the wrong place can mess up
the return result. I often write code to return an explicit result.
After not making any sense of why it was erroring our, I restored the
non debug version of the mkmf.rb

so I just did:
yum install gcc-c++ autoconf make

and deleted the ext directory and tried ‘gem install pg’ and go the
same error.

in the mkmf.log I saw this:


“gcc -E -I. -I/usr/lib/ruby/1.8/i386-linux -I. -D_FILE_OFFSET_BITS=64
-I/usr/include -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
-fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -
mtune=atom -fasynchronous-unwind-tables -fno-strict-aliasing -fPIC
conftest.c -o conftest.i”

checked program was:
/* begin /
1: #include <libpq-fe.h>
/
end */

I saw that the build deletes conftest.c, so I created a conftest.c
with just:
#include <libpq-fe.h>
then ran the gcc command above and it created a conftest.i file

just in case forks are still struggling with this(at least I was this
morning on fedora core 14 beta). I solved the same problem by installing
required development tools as:

sudo yum groupinstall ‘development tools’

Cheers!

…chad

Jedrin wrote:

I get these errors :

gem install pg – --with-pgsql-include-dir=’/usr/include/pgsql’ –
with-pgsql-lib-dir=’/usr/lib/pgsql’
Building native extensions. This could take a while…
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.

/usr/bin/ruby extconf.rb --with-pgsql-include-dir=/usr/include/pgsql –
with-pgsql-lib-dir=/usr/lib/pgsql
can’t find header files for ruby.

Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/
pg-0.9.0 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/pg-0.9.0/ext/
gem_make.out

from yum list postgres*, the relevant stuff I have installed is:

Installed Packages
postgresql.i686
8.4.2-1.fc12 @updates
postgresql-devel.i686
8.4.2-1.fc12 @updates
postgresql-libs.i686
8.4.2-1.fc12 @updates
postgresql-server.i686
8.4.2-1.fc12 @updates

I had same problem. But It’s solved after run

yum install ruby-devel

Thanks.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs