1

I am not sure what happened - I know Postgres was working right after the upgrade to Lion, but it is not working anymore. I have Xcode 4 installed.

error:

$ gem install pg -- --with-pg-config=/usr/bin/pg_config
Building native extensions.  This could take a while...
ERROR:  Error installing pg:
    ERROR: Failed to build gem native extension.

        /Users/Me/.rvm/rubies/ruby-1.9.2-p318/bin/ruby extconf.rb --with-pg-config=/usr/bin/pg_config
Using config values from /usr/bin/pg_config
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/Me/.rvm/rubies/ruby-1.9.2-p318/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
/Users/Me/.rvm/rubies/ruby-1.9.2-p318/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/Me/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/mkmf.rb:452:in `try_cpp'
    from /Users/Me/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/mkmf.rb:853:in `block in find_header'
    from /Users/Me/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/mkmf.rb:693:in `block in checking_for'
    from /Users/Me/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/mkmf.rb:280:in `block (2 levels) in postpone'
    from /Users/Me/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/mkmf.rb:254:in `open'
    from /Users/Me/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/mkmf.rb:280:in `block in postpone'
    from /Users/Me/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/mkmf.rb:254:in `open'
    from /Users/Me/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/mkmf.rb:276:in `postpone'
    from /Users/Me/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/mkmf.rb:692:in `checking_for'
    from /Users/Me/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/mkmf.rb:852:in `find_header'
    from extconf.rb:40:in `<main>'


Gem files will remain installed in /Users/Me/.rvm/gems/ruby-1.9.2-p318/gems/pg-0.13.2 for inspection.
Results logged to /Users/Me/.rvm/gems/ruby-1.9.2-p318/gems/pg-0.13.2/ext/gem_make.out

EDIT*** I tried installing postgres via homebrew and got the following errors:

Warning: You have no /usr/bin/cc.
This means you probably can't build *anything*. You need to install the Command
Line Tools for Xcode. You can either download this from http://connect.apple.com
or install them from inside Xcode's Download preferences. Homebrew does not
require all of Xcode! You only need the Command Line Tools package!
Warning: Setting DYLD_LIBRARY_PATH can break dynamic linking.
You should probably unset it.
Warning: Your Homebrew is outdated
You haven't updated for at least 24 hours, this is a long time in brewland!
Warning: Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected dylibs:
    /usr/local/lib/libruby.1.8.7.dylib
Warning: Unbrewed static libraries were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected static libraries:
    /usr/local/lib/libruby-static.a
Warning: Your compilers are different from the standard versions for your Xcode.
If you have Xcode 4.3 or newer, you should install the Command Line Tools for
Xcode from within Xcode's Download preferences.
Otherwise, you should reinstall Xcode.
Warning: /usr/bin occurs before /usr/local/bin
This means that system-provided programs will be used instead of those
provided by Homebrew. The following tools exist at both paths:

    bundle
    edit_json.rb
    erb
    erubis
    gem
    irb
    prettify_json.rb
    rails
    rake
    rake2thor
    rdoc
    ri
    ruby
    testrb
    thor
    tt
    update_rubygems

Consider amending your PATH so that /usr/local/bin
is ahead of /usr/bin in your PATH.
Warning: Your Xcode is configured with an invalid path.
You should change it to the correct path. Please note that there is no correct
path at this time if you have *only* installed the Command Line Tools for Xcode.
If your Xcode is pre-4.3 or you installed the whole of Xcode 4.3 then one of
these is (probably) what you want:

    sudo xcode-select -switch /Developer
    sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
fatfrog
  • 2,118
  • 1
  • 23
  • 46
  • It might help to post your `mkmf.log` from the `ext` directory. It often has additional specifics about why the build failed that can help diagnose the problem. – Michael Granger Apr 18 '12 at 00:33

2 Answers2

2

Trying forcing pg gem to build with the 64 bit libpg version.

ARCHFLAGS='-arch x86_64' gem install pg

Chris Ledet
  • 11,458
  • 7
  • 39
  • 47
1

Check out the following blog post: Using MySQL and Postgres on Mac OS X (Tiger) with RoR

BluesRockAddict
  • 15,525
  • 3
  • 37
  • 35
  • 1
    You should be able to just do *brew uninstall postgresql* and then *brew install postgresql* to fix this issue. – BluesRockAddict Apr 16 '12 at 17:53
  • BTW - make sure you have the **latest** Xcode from App Store. – BluesRockAddict Apr 16 '12 at 17:59
  • I got this for the uninstall - $ brew uninstall postgresql Error: No such keg: /usr/local/Cellar/postgresql Also I have Xcode installed from the App store, but I read here that you need to run something else: http://stackoverflow.com/questions/6935146/bundle-update-install-fail-after-os-x-lion-upgrade-rails-3 - but I can't find an executible to run in my application folder? – fatfrog Apr 16 '12 at 18:15
  • I did and saw nothing, I tried installing via homebrew and got this (I put the full output in the question) Warning: Your Xcode is configured with an invalid path. You should change it to the correct path. Please note that there is no correct path at this time if you have *only* installed the Command Line Tools for Xcode. If your Xcode is pre-4.3 or you installed the whole of Xcode 4.3 then one of these is (probably) what you want: sudo xcode-select -switch /Developer sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer – fatfrog Apr 16 '12 at 18:35
  • 1
    I would suggest trying to uninstall Xcode 4: **sudo /Developer/Library/uninstall-devtools --mode=all**, re-install it from App Store and then re-try gem pg installation. – BluesRockAddict Apr 16 '12 at 18:38