【问题标题】:OSX Lion - can't install Postgres gemOSX Lion - 无法安装 Postgres gem
【发布时间】:2012-04-16 17:39:30
【问题描述】:

我不确定发生了什么 - 我知道 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

【问题讨论】:

  • ext 目录中发布您的mkmf.log 可能会有所帮助。它通常包含有关构建失败原因的其他详细信息,可以帮助诊断问题。

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


【解决方案1】:

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

ARCHFLAGS='-arch x86_64' gem install pg

【讨论】:

    【解决方案2】:

    【讨论】:

    • 您应该能够执行 brew uninstall postgresql 然后 brew install postgresql 来解决此问题。
    • 顺便说一句 - 确保您拥有来自 App Store 的 最新 Xcode。
    • 我得到了这个用于卸载 - $ brew uninstall postgresql 错误:没有这样的小桶:/usr/local/Cellar/postgresql 我也从 App Store 安装了 Xcode,但我在这里读到你需要运行其他东西:stackoverflow.com/questions/6935146/… - 但我在我的应用程序文件夹中找不到可运行的可执行文件?
    • 我什么也没看到,我尝试通过自制软件安装并得到了这个(我将完整的输出放在问题中)警告:您的 Xcode 配置了无效的路径。您应该将其更改为正确的路径。请注意,如果您安装了 Xcode 命令行工具,则此时没有正确的路径。如果您的 Xcode 是 4.3 之前的版本,或者您安装了整个 Xcode 4.3,那么其中之一就是(可能)您想要的: sudo xcode-select -switch /Developer sudo xcode-select -switch /Applications/Xcode.app/Contents/开发者
    • 我建议尝试卸载 Xcode 4:sudo /Developer/Library/uninstall-devtools --mode=all,从 App Store 重新安装,然后重新尝试 gem pg 安装。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-29
    • 2012-08-10
    • 1970-01-01
    • 2018-10-11
    • 2012-12-07
    • 1970-01-01
    相关资源
    最近更新 更多