2015-02-08 48 views
0

大家好,我想在我的MacOS安裝postgre:約塞米蒂10.10.2創業板安裝postgre錯誤 - 蘋果10.10

首先,我這樣做是因爲我想部署在Heroku我的應用程序,不支持SQLite所以我做了以下幾點:

group :development, :test do 
    gem 'sqlite3' 
    gem 'sqlite3-ruby', :require => 'sqlite3' 
end 

group :production do 
    gem 'pg' 
end 

所以當我部署它在heroku上工作正常。

但現在我不能運行「包安裝」了的原因,它說 我用命令:

sudo gem install pg -- 
--with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config 
--with-pg-include='/Applications/Postgres.app/Contents/Versions/9.3/include/' 
-–with-pg-lib=/usr/lib 

(我曾單獨審判他們中的每一個之前也)

這裏是什麼我得到:

sudo gem install pg -- 
--with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config 
--with-pg-include='/Applications/Postgres.app/Contents/Versions/9.3/include/' 
–with-pg-lib=/usr/lib 
Building native extensions with: '--with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config --with-pg-include=/Applications/Postgres.app/Contents/Versions/9.3/include/ –with-pg-lib=/usr/lib' 
This could take a while... 
ERROR: Error installing pg: 
    ERROR: Failed to build gem native extension. 

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -r ./siteconf20150208-28855-hgneo3.rb extconf.rb --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config --with-pg-include=/Applications/Postgres.app/Contents/Versions/9.3/include/ –with-pg-lib=/usr/lib 
Using config values from /Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config 
checking for libpq-fe.h... yes 
checking for libpq/libpq-fs.h... yes 
checking for pg_config_manual.h... yes 
checking for PQconnectdb() in -lpq... no 
checking for PQconnectdb() in -llibpq... no 
checking for PQconnectdb() in -lms/libpq... no 
Can't find the PostgreSQL client library (libpq) 

*** 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. 
    extconf failed, exit code 1 

Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/pg-0.18.1 for inspection. 
Results logged to /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-14/2.0.0/pg-0.18.1/gem_make.out 

我不明白他爲什麼不能得到PQconnectdb()? 我在這裏錯過了什麼嗎?

在此先感謝=)

回答

0

雖然你基本上不使用你的本地計算機上的「生產」的環境中,你仍然需要在您的計算機上安裝的Postgres,使一切正常工作。根據你的日誌,似乎你沒有正確安裝postgres。

我建議使用homebrew進行安裝:

brew install postgres 

通過自制軟件在安裝後的Postgres安裝pg寶石時,你不應該得到這個錯誤。

如果您使用其他方法進行安裝,則可能需要在安裝pg gem時添加一些參數。下面是一些參考:

Installing PostgreSQL gem under Ubuntu and Mac

Can't find the PostgreSQL client library (libpq)

+0

我已經有了: > sudo的釀造安裝的Postgres 警告:在PostgreSQL-9.4.0已經安裝 我還與postgre.app安裝:http://postgresapp.com/ 我相信我失去了一些東西^^ – MrHello 2015-02-08 13:06:09

+1

1.你不應該安裝兩次postgres。我建議刪除postgres.app安裝的那個。 2.如果你已經安裝了它,你應該通過'postgres -D/usr/local/var/postgres'來啓動你的postgres服務器(更多信息請參考'brew info postgres') – Brian 2015-02-08 14:39:34