安装pg gem;错误:无法构建gem本机扩展 [英] Installing pg gem; ERROR: Failed to build gem native extension

查看:130
本文介绍了安装pg gem;错误:无法构建gem本机扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在更新到 OS X 10.9 Mavericks 之后,我尝试启动Rails 3应用程序,但是与PG数据库的连接无法正常工作。检查PGAdmin III,数据库仍然存在并且可以正常工作。
所以我试图重新安装pg gem:

After updating to OS X 10.9 Mavericks I tried to start a Rails 3 app, but the connection to the PG database was not working. Checking on PGAdmin III, the database is still there and it works fine. So I tried to reinstall the pg gem:

gem uninstall pg
gem install pg

但是最后一条命令没有成功,并给出以下错误:

But the last command doesn't succeed, and gives the following error:


构建本机扩展。这可能需要一段时间...错误:错误
安装pg:

Building native extensions. This could take a while... ERROR: Error installing pg:

错误:无法构建gem本机扩展。

ERROR: Failed to build gem native extension.

    /Users/XXX/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb checking for pg_config... yes Using config values from

/ usr / local / bin / pg_config
* extconf.rb失败* 由于某种原因(可能缺少必需的库和/或头文件)而无法创建Makefile。检查
mkmf.log文件以获取更多详细信息。您可能需要配置
选项。

/usr/local/bin/pg_config * 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.

/Users/XXX/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1 /mkmf.rb:381:在
`try_do'中:编译器无法生成可执行文件。

/Users/XXX/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file.

(RuntimeError)您必须首先安装开发工具。从
/Users/XXX/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:461:in
try_link0'从
/Users/XXX/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:476:in
try_link 'from extconf.rb:39:in`'

(RuntimeError) You have to install development tools first. from /Users/XXX/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:461:in try_link0' from /Users/XXX/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:476:in try_link' from extconf.rb:39:in `'

我想这个问题与 Xcode开发人员工具

I guess the problem is related to the Xcode developer tools. I updated Xcode to the latest version, but that didn't solve the problem. Do you know how to fix it?

推荐答案

使用自制软件为我修复了此问题:

Using homebrew fixed this for me:

gem uninstall pg
brew install apple-gcc42
gem install pg

编辑:我也手动安装了 devtools

I also manually installed "devtools"

xcode-select --install

这篇关于安装pg gem;错误:无法构建gem本机扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆