2014-01-23 33 views
3

只做了一個簡單的bundle update,並且得到了與PostgreSQL的pg gem相關的惱人錯誤。我的系統上沒有安裝PostgreSQL(除非它自動爲Mac OS X 10.9.1安裝)。這從來都不是一個問題。有任何想法嗎?對於Mac OS X更新pg gem從0.17.0到0.17.1時出錯10.9.1

Using jquery-rails (3.0.4) 
Using jquery-rails-cdn (1.0.1) 
Installing liquid (2.6.1) 
Using paperclip (3.5.2) 
Installing pg (0.17.1) 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. 

     /Users/scott/.rvm/rubies/ruby-1.9.3-p194/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=/Users/scott/.rvm/rubies/ruby-1.9.3-p194/bin/ruby 
    --with-pg 
    --without-pg 
    --with-pg-config 
    --without-pg-config 
    --with-pg_config 
    --without-pg_config 
    --with-pg-dir 
    --without-pg-dir 
    --with-pg-include 
    --without-pg-include=${pg-dir}/include 
    --with-pg-lib 
    --without-pg-lib=${pg-dir}/lib 


Gem files will remain installed in /Users/scott/.rvm/gems/[email protected]/gems/pg-0.17.1 for inspection. 
Results logged to /Users/scott/.rvm/gems/[email protected]/gems/pg-0.17.1/ext/gem_make.out 

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


$ gem list pg 

*** LOCAL GEMS *** 

pg (0.17.0, 0.16.0, 0.15.1, 0.15.0, 0.14.1) 

UPDATE:根據要求,這是我的mkmf.log文件

find_executable: checking for pg_config... -------------------- no 

-------------------- 

find_header: checking for libpq-fe.h... -------------------- no 

"/usr/bin/gcc-4.2 -o conftest -I/Users/scott/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/x86_64-darwin12.2.0 -I/Users/scott/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/ruby/backward -I/Users/scott/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/Users/mpapis/.rvm/rubies/ruby-1.9.3-p194/include -fno-common -pipe conftest.c -L. -L/Users/scott/.rvm/rubies/ruby-1.9.3-p194/lib -L. -L/Users/mpapis/.rvm/rubies/ruby-1.9.3-p194/lib  -lruby.1.9.1 -lpthread -ldl -lobjc " 
ld: warning: directory not found for option '-L/Users/mpapis/.rvm/rubies/ruby-1.9.3-p194/lib' 
checked program was: 
/* begin */ 
1: #include "ruby.h" 
2: 
3: int main() {return 0;} 
/* end */ 

"/usr/bin/gcc-4.2 -E -I/Users/scott/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/x86_64-darwin12.2.0 -I/Users/scott/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/ruby/backward -I/Users/scott/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/Users/mpapis/.rvm/rubies/ruby-1.9.3-p194/include -fno-common -pipe conftest.c -o conftest.i" 
conftest.c:3:10: fatal error: 'libpq-fe.h' file not found 
#include <libpq-fe.h> 
     ^
1 error generated. 
checked program was: 
/* begin */ 
1: #include "ruby.h" 
2: 
3: #include <libpq-fe.h> 
/* end */ 

-------------------- 

更新2:的pgGemfile唯一一提的是在這裏:

group :development do 
    gem 'sqlite3' 
end 
group :production do 
    gem 'pg' 
end 
+0

提供您'mkmf.log' –

+0

@majioa - 我把它添加到問題 –

回答

5

最簡單的方法是安裝Postgres.app

然後做:

$ gem install pg -v '0.17.1' && bundle update 

編輯:不要忘了add the relevant directories into your PATH

+0

我真的需要安裝Postgres嗎?我從來沒有過。只有當我將應用程序推送到Heroku時,我纔在我的Mac上使用Postgres。 –

+0

顯然'pg' gem對本地庫有依賴關係。您的Gemfile中的':production'組是否是您的'pg'寶石?你能粘貼你的Gemfile嗎? – Agis

+0

'pg'在我的':production'組中。我粘貼了這個部分,'Gemfile'中只出現'pg'這個單詞。 –

1

嘗試重新安裝pg寶石gem install pg --with-pg-config=/path/to/pg_config


我recomended安裝此應用Postgres 並安裝寶石:
env ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config

+0

該訣竅對我的感謝! – thomasstephn

+0

@thomasstephn我的榮幸! –

0

新手一個細節的解釋。在做完git clean -xdf之後我有同樣的錯誤。出於某種原因,我做到這一點後,我無法啓動我的本地Rails服務器,也不會捆綁安裝/更新工作給出相同的PGM錯誤。它基本上忽略了我的gemfile中的以下內容:

group :production do 
    gem 'pg',    '0.17.1' 
    gem 'rails_12factor', '0.0.2' 
end 

我能夠通過再次運行以下行來修復問題。我想它已經設置爲默認值,因爲我現在也可以在更新時使用bundle install。

bundle install --without production 
+0

這不提供問題的答案。要批評或要求作者澄清,在他們的帖子下留下評論 - 你總是可以評論你自己的帖子,一旦你有足夠的[聲譽](http://stackoverflow.com/help/whats-reputation),你會能夠[評論任何帖子](http://stackoverflow.com/help/privileges/comment)。 – carlodurso

+0

這個*確實*提供了一個潛在的解決方案...只要它實際適用於O/P –