我正在尝试使用Postgres捆绑一个新的rails应用程序。
每次尝试捆绑时都会收到此错误。
Errno::EACCES: Permission denied - /usr/local/var/rbenv/versions/2.0.0- p353/lib/ruby/gems/2.0.0/gems/pg-0.17.0/.gemtest
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.
当我尝试用sudo安装pg gem时,它说:
➜ wandrr sudo gem install pg -v '0.17.0'
Password:
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/usr/local/var/rbenv/versions/2.0.0-p353/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 ***
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.
我已阅读pg app的文档,但仍不确定。
我的zshrc文件看起来像这样
# Customize to your needs...
PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"
export RBENV_ROOT=/usr/local/var/rbenv
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
我使用自制软件来安装rbenv和ruby-build。
我已经检查过ruby gems是最新的。
有关如何让pg gem成功的任何建议?
解决方案
我试图让gem install pg
工作的最初问题是由于postgres应用无法正常工作。通过检查我的ZSHRC文件中设置的路径来解决该问题。
现在看来是这样的:
# Customize to your needs...
PATH=/Applications/Postgres93.app/Contents/MacOS/bin:$PATH
eval "$(rbenv init -)";
注意:文档说要使用
PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"
然而,此实例中的应用程序称为Postgres93.app