2015-05-02 209 views
0

当我试图在我的mac上运行我的第一个rails应用程序时,我一直有访问被拒绝的错误。安装pg gem时遇到问题

当我运行bundle install我得到

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

然后我跑gem install pg -v '0.18.1',并收到以下错误

Building native extensions. This could take a while... 
ERROR: Error installing pg: 
ERROR: Failed to build gem native extension. 
/Users/foo/.rvm/rubies/ruby-2.2.1/bin/ruby -r ./siteconf20150502-79500-1qqztpf.rb 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. 
Gem files will remain installed in /Users/foo/.rvm/gems/ruby-2.2.1/gems/pg-0.18.1 for inspection. 
Results logged to /Users/foo/.rvm/gems/ruby-2.2.1/extensions/x86_64-darwin-14/2.2.0-static/pg-0.18.1/gem_make.out 
+0

看看这个帖子的答案http://stackoverflow.com/questions/6040583/cant-find-the-libpq-fe-h-header-when-trying-to-install-pg-gem – Hoa

+0

谢谢!这对我来说很懒。抱歉 – grabury

回答

0

你只在生产环境中运行PostgreSQL的?在这种情况下,要确保它只是分组进行生产在你的Gemfile:

group :production do 
    gem pg, '0.18.1' 
end 

之后,请务必束运行通过阐明不安装生产宝石安装:

$ bundle install --without production 

我希望这有助于。