Postgresql Gem没有安装

时间:2014-04-07 07:34:25

标签: ruby-on-rails ruby postgresql homebrew

我一直在尝试运行捆绑安装,但我收到以下错误:

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    /Users/fr/.rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
 --with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***

按照说明操作后,我收到以下错误:

gem install pg -v '0.17.0'                                                    ⏎
Building native extensions.  This could take a while...
ERROR:  Error installing pg:
    ERROR: Failed to build gem native extension.

    /Users/fr/.rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
 --with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***

我按照之前报告的类似问题提供的说明进行操作。请参阅Installing PG gem - failure to build native extension

但这没有帮助,如下所示:

brew install postgresql
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:
==> /usr/local/Cellar/postgresql/9.3.4/bin/initdb /usr/local/var/postgres
==> Summary
  /usr/local/Cellar/postgresql/9.3.4: 2928 files, 38M


brew link postgresql
Linking /usr/local/Cellar/postgresql/9.3.4...
Warning: Could not link postgresql. Unlinking...
Error: Could not symlink file: /usr/local/Cellar/postgresql/9.3.4/share/man/man7/WITH.7
/usr/local/share/man/man7 is not writable. You should change its permissions.

我的两个问题是:

  1. 如何解决与' pg'相关的问题?宝石?
  2. 要解决此问题,是否有必要修改 brew link postgresql 输出中提到的文件的读写权限?

1 个答案:

答案 0 :(得分:0)

我设法解决了问题。主要问题是 pg版本 - 0.17.0 。我安装了最新的Postgres.app并在安装后验证版本为 0.17.1 。然后我将gem文件修改为gem 'pg'并运行bundle update。感谢大家的建议和链接。