Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm trying to install pg through gem, but I have problems doing so. Others seem to have similar issues but none of what I found on the internet helps in my case.

Here is what's happening. I try to install pg with the following command:

gem install pg -v 0.15.1 -- --with-pg_config=/opt/local/lib/postgresql92/ --with-pg-include=/opt/local/include/postgresql92/ --with-pg-lib=/opt/local/lib/postgresql92 --with-opt-lib=/opt/local/lib

This outputs:

 This could take a while...ERROR:  Error installing pg:
    ERROR: Failed to build gem native extension.

     /Users/XXX/.rvm/rubies/ruby-1.9.2-p320/bin/ruby extconf.rb --with-pg_config=/opt/local/lib/postgresql92/ --with-pg-include=/opt/local/include/postgresql92/ --with-pg-lib=/opt/local/lib/postgresql92
 Using config values from /opt/local/lib/postgresql92/
 sh: /opt/local/lib/postgresql92/: is a directory
 sh: /opt/local/lib/postgresql92/: 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=/Users/XXX/.rvm/rubies/ruby-1.9.2-p320/bin/ruby
    --with-pg
    --without-pg
    --with-pg-dir
    --without-pg-dir
    --with-pg-include=${pg-dir}/include
    --with-pg-lib=${pg-dir}/lib
    --with-pg-config
 /Users/XXX/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:368:in `try_do': The complier failed to generate an executable file. (RuntimeError)
 You have to install development tools first.
    from /Users/XXX/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:452:in `try_cpp'
    from /Users/XXX/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:853:in `block in find_header'
    from /Users/XXX/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:693:in `block in checking_for'
    from /Users/XXX/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:280:in `block (2 levels) in postpone'
    from /Users/XXX/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:254:in `open'
    from /Users/XXX/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:280:in `block in postpone'
    from /Users/XXX/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:254:in `open'
    from /Users/XXX/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:276:in `postpone'
    from /Users/XXX/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:692:in `checking_for'
    from /Users/XXX/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:852:in `find_header'
    from extconf.rb:43:in `<main>'


 Gem files will remain installed in /Users/XXX/.rvm/gems/ruby-1.9.2-p320/gems/pg-0.15.1 for inspection.
 Results logged to /Users/XXX/.rvm/gems/ruby-1.9.2-p320/gems/pg-0.15.1/ext/gem_make.out

This is mkmf.log:

 "gcc-4.2 -o conftest -I/Users/XXX/.rvm/rubies/ruby-1.9.2-p320/include/ruby-1.9.1/x86_64-darwin10.8.0 -I/Users/XXX/.rvm/rubies/ruby-1.9.2-p320/include/ruby-1.9.1/ruby/backward -I/Users/XXX/.rvm/rubies/ruby-1.9.2-p320/include/ruby-1.9.1 -I. -I/opt/local/include/postgresql92/ -I/opt/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -I  -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wshorten-64-to-32 -Wno-long-long  -fno-common -pipe conftest.c  -L. -L/Users/jonklein/.rvm/rubies/ruby-1.9.2-p320/lib -> L/opt/local/lib/postgresql92 -L/opt/local/lib -L.  -L -Wl,-rpath,     -lruby.1.9.1-static  - lpthread -ldl -lobjc "

 ld: -L must be immediately followed by a directory path (no space)
 collect2: ld returned 1 exit status
 checked program was:
 /* begin */
 1: #include "ruby.h"
 2:
 3: int main() {return 0;}
 /* end */

It seems as though the gcc command is not correctly used.

My OS is Mac OS X 10.6.8. I'm using rvm 1.22.3 (stable) with ruby 1.9.2p320 (2012-04-20 revision 35421), gem version 2.0.7, gcc-4.2. I installed postgresql-9.2.4-1 via the installer provided by http://www.postgresql.org/download/macosx/.

Can anyone help, please?

share|improve this question
    

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.