Rails:在 OS X 上安装 PG gem - 无法构建本机扩展

问题描述:

似乎许多其他人在安装 pg gem 时遇到了问题.为其他人提出的解决方案都没有为我工作.

It seems many others have had problems installing the pg gem. None of the solutions posed for others have worked for me.

我尝试安装 pg gem 和 postgres.app.pg gem 不会安装.我得到的第一个错误是:

I have tried to install the pg gem and postgres.app. The pg gem won't install. The first error I get is:

安装 pg (0.17.0) 时出错,Bundler 无法继续.打包前确保 gem install pg -v '0.17.0' 成功.

An error occurred while installing pg (0.17.0), and Bundler cannot continue. Make sure that gem install pg -v '0.17.0' succeeds before bundling.

关于将我的 gem install 指向 pg 配置的安装建议失败,并显示以下错误消息(本论坛上的许多其他人都遇到过):

The installation advice about pointing my gem install to the config for pg fails with the following error message (which many others on this forum have encountered):

Failed to build native extensions... Results logged to /Users/melanie/.rvm/gems/ruby-1.9.3-p448/gems/pg-0.17.0/ext/gem_make.out

我不知道如何查找或访问此日志文件以搜索更多线索.

I don't know how to find or access this log file to search for further clues.

当我尝试使用 sudo apt-get install 命令时,我也收到一条错误消息(找不到命令).在过去的 6 个小时里,我已经浏览了这个论坛,尝试了每一条建议,让 pg 与我的 rails 项目一起工作.

I also get an error message (command not found) when I try using the sudo apt-get install command. I've scoured this forum for the last 6 hours, trying each piece of advice to get pg working with my rails project.

我找不到有关如何更改路径的建议,或者具体来说,需要进行哪些更改.我的 which pg_config 返回一个文件源.我已经将它与命令一起使用,以使用该配置安装 pg.失败了.

I can't find advice about how to change a path, or specifically, what change is required. My which pg_config returns a file source. I've used that with a command to install pg using that config. It fails.

有很多人遇到过这个问题.许多答案都建议自制.我不得不删除它,因为它引发了其他问题.

There are so many people that have had trouble with this. Many answers suggest homebrew. I've had to remove that because it threw up other issues.

我遇到了同样的错误,直到我下载了 OS X 10.9 (Mavericks).唉,又是一个操作系统升级头疼的问题.

Same error for me and I didn't experience it until I downloaded OS X 10.9 (Mavericks). Sigh, another OS upgrade headache.

这是我修复它的方法(使用自制软件):

Here's how I fixed it (with homebrew):

  • 安装另一个构建的 Xcode 工具(在终端中输入 brew update 将提示您更新 Xcode 构建工具)
  • 酿造更新
  • brew install postgresql
  • Install another build of Xcode Tools (typing brew update in the terminal will prompt you to update the Xcode build tools)
  • brew update
  • brew install postgresql

在那之后 gem install pg 为我工作.

After that gem install pg worked for me.