2011-10-09 131 views
2

我剛剛安裝的PostgreSQL的9.x在我的Mac,並試圖將pg我的Gemfile後運行bundle install的時候,我得到:爲什麼不安裝pg gem?

Installing pg (0.11.0) with native extensions /Library/Ruby/Site/1.8/rubygems/installer.rb:529:in `build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError) 

    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/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. 

Provided configuration options: 
--with-opt-dir 
--without-opt-dir 
--with-opt-include 
--without-opt-include=${opt-dir}/include 
--with-opt-lib 
--without-opt-lib=${opt-dir}/lib 
--with-make-prog 
--without-make-prog 
--srcdir=. 
--curdir 
--ruby=/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby 
--with-pg 
--without-pg 
--with-pg-dir 
--without-pg-dir 
--with-pg-include 
--without-pg-include=${pg-dir}/include 
--with-pg-lib 
--without-pg-lib=${pg-dir}/lib 
--with-pg-config 
--without-pg-config 
--with-pg_config 
--without-pg_config 


Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/pg-0.11.0 for inspection. 
Results logged to /Library/Ruby/Gems/1.8/gems/pg-0.11.0/ext/gem_make.out 
from /Library/Ruby/Site/1.8/rubygems/installer.rb:482:in `each' 
from /Library/Ruby/Site/1.8/rubygems/installer.rb:482:in `build_extensions' 
from /Library/Ruby/Site/1.8/rubygems/installer.rb:156:in `install' 
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/source.rb:101:in `install' 
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/rubygems_integration.rb:78:in `preserve_paths' 
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/source.rb:91:in `install' 
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/installer.rb:58:in `run' 
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/rubygems_integration.rb:93:in `with_build_args' 
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/installer.rb:57:in `run' 
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/spec_set.rb:12:in `each' 
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/spec_set.rb:12:in `each' 
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/installer.rb:49:in `run' 
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/installer.rb:8:in `install' 
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/cli.rb:222:in `install' 
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/vendor/thor/task.rb:22:in `send' 
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/vendor/thor/task.rb:22:in `run' 
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task' 
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/vendor/thor.rb:246:in `dispatch' 
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/vendor/thor/base.rb:389:in `start' 
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/bin/bundle:13 
from /usr/bin/bundle:19:in `load' 
from /usr/bin/bundle:19 

回答

2

的線索是:

No pg_config... trying anyway. If building fails, please try again with --with-pg-config=/path/to/pg_config

您需要將其指向pg_config文件。

所以尋找到pg_config文件並運行此:

gem install pg --with-pg-config=/path/to/pg_config