ruby-on-rails-3 - Gem Install PG 神秘报错extconf.rb相关

标签 ruby-on-rails-3 postgresql rubygems pg

我正在尝试更新我的 pg gem,但出现以下错误

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

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


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

我尝试搜索 mkmf.log 文件,但找不到。我尝试了几种方法,包括放置 pg_conf 文件的目录,但到目前为止没有任何效果。我在 10.6.8 上尝试这个。雪豹和我的 ruby 是 1.9.2-p290。我已经安装了 pg 9.1。

我试过这个:

gem 安装 pg

gem install pg -- --with-pg-config=/usr/local/bin/pg_config

这个问题出现在我更换我的macbook pro硬盘并通过时间机器恢复系统后。我应该重新安装 XCode 吗?还有其他建议吗?

最佳答案

我遇到了类似的问题。我通过更新 rvm 绕过了它:

rvm get latest
rvm reload
rvm --force install 1.9.2

关于ruby-on-rails-3 - Gem Install PG 神秘报错extconf.rb相关,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9593366/

相关文章:

ruby-on-rails - 如何根据用户当前时区制作今天的日期方法?

sql - 计算每个最小网络 block 的记录(间隔)

ruby-on-rails - 按域访问 Rails cookie

ruby - Gem 开发工作流程

rubygems - gem bundle从本地资源安装

ruby - 使用 Formtastic 的单表继承

ruby-on-rails - 将 Rails 应用程序集成到 WordPress 制作的网站中

ruby-on-rails - 为什么 "g controller"不创建 View 文件?

python - 使用 PostgreSQL 时使用 COPY 命令处理错误

sql - 模式是否应该始终在 SQL 语句中显式定义?