【发布时间】:2014-04-07 07:34:25
【问题描述】:
我一直在尝试运行 bundle install,但出现以下错误:
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.
我的两个担忧是:
- 如何解决与“pg”gem 相关的问题?
- 要解决此问题,是否需要修改 brew link postgresql 输出中提到的文件的读写权限?
【问题讨论】:
-
检查权限:
ls -ld /usr/local/Cellar并打开它们进行写入:sudo chmod a+w /usr/local/Cellar并尝试再次安装brew install postgresql -
嗨@Monk_Code,我尝试了你的建议。检查目录后,我看到了以下输出:
ls -ld /usr/local/Cellar drwxrwxrwx 21 fr wheel 714 Apr 7 10:49 /usr/local/Cellar在尝试brew install 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. -
大家好,我设法解决了这个问题。主要问题是 pg 版本 - 0.17.0。我安装了最新的 Postgres.app 并在安装时验证了版本是 0.17.1。然后我将 gem 文件修改为简单的
gem 'pg'并运行bundle update。感谢大家的建议和链接。
标签: ruby-on-rails ruby postgresql homebrew