2015-02-08 50 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