【问题标题】:Stuck trying to build Pg gem on OS X 10.8.5试图在 OS X 10.8.5 上构建 Pg gem
【发布时间】:2014-01-27 05:28:51
【问题描述】:

终端中“捆绑安装”的结果:

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

终端中“which psql”的结果:

/usr/bin/psql

/etc/paths 如下所示:

/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/bin
/Applications/Postgres93.app/Contents/MacOS/bin

gem install pg 的结果

/usr/local/rvm/rubies/ruby-1.9.3-p194/bin/gem:4: warning: Insecure world writable dir /usr/local in PATH, mode 040777
Building native extensions.  This could take a while...
ERROR:  Error installing pg:
    ERROR: Failed to build gem native extension.

        /usr/local/rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb

brew install postgres 的结果:

Warning: A newer Command Line Tools release is available
The standalone package can be obtained from
https://developer.apple.com/downloads/,
or it can be installed via Xcode's preferences.
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/postgresql-
######################################################################## 100.0%
==> Pouring postgresql-9.3.2.mountain_lion.bottle.tar.gz
==> Caveats
If builds of PostgreSQL 9 are failing and you have version 8.x installed,
you may need to remove the previous version first. See:
  https://github.com/Homebrew/homebrew/issues/issue/2510

To migrate existing data from a previous major version (pre-9.3) of PostgreSQL, see:
  http://www.postgresql.org/docs/9.3/static/upgrading.html

When installing the postgres gem, including ARCHFLAGS is recommended:
  ARCHFLAGS="-arch x86_64" gem install pg

To install gems without sudo, see the Homebrew wiki.

To have launchd start postgresql at login:
    ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
Then to load postgresql now:
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
Or, if you don't want/need launchctl, you can just run:
    postgres -D /usr/local/var/postgres
Warning: Could not link postgresql. Unlinking...
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
You can try again using `brew link postgresql'

Possible conflicting files are:
Warning: Could not link postgresql. Unlinking...
Error: Permission denied - /usr/local/lib/pkgconfig

不确定我还能尝试什么 - 我也安装了 Postgres 应用程序。

【问题讨论】:

  • 关于brew install postgres:看起来/usr/local 的权限不对。 brew doctorls -ld /usr/localls -ld /usr/local/lib 报告什么?
  • 总是解释你是如何在你的系统上安装 PostgreSQL 的。 homebrew 是这里唯一安装的 PostgreSQL,还是您尝试通过安装 PostgreSQL 的第二个副本来解决问题?

标签: ruby-on-rails ruby macos postgresql psql


【解决方案1】:

如果您使用 Postgress.app,则需要在安装 Gem 时指定 --with-pg-config

详情请见this Q&A

【讨论】:

  • 是的。而安装另一个版本的 PostgreSQL 是不是的答案。 “在运行随机命令直到它似乎工作之前一直连枷”学校似乎在 Rails 人群的一个子集(可能有很多新手程序员)中很受欢迎,并产生了像这个问题这样的痛苦。感谢您提供明确的“正确方式”答案。
猜你喜欢
  • 2014-07-13
  • 2013-10-16
  • 2012-09-20
  • 2015-02-12
  • 2013-10-12
  • 2015-01-21
  • 1970-01-01
  • 1970-01-01
  • 2018-02-13
相关资源
最近更新 更多