OSX Lion - 无法安装Postgres gem

时间:2012-04-16 17:39:30

标签: ruby-on-rails postgresql gem osx-lion

我不确定发生了什么 - 我知道Postgres在升级到Lion之后正在工作,但它不再起作用了。我安装了Xcode 4。

错误:

$ 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

编辑***我尝试通过自制软件安装postgres并遇到以下错误:

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

2 个答案:

答案 0 :(得分:2)

尝试强制使用64位libpg版本构建pg gem。

ARCHFLAGS='-arch x86_64' gem install pg

答案 1 :(得分:1)

相关问题