gem install postgre error - Mac 10.10

时间:2015-02-08 12:10:36

标签: ruby-on-rails-3 ruby-on-rails-4 osx-yosemite pg

大家好我想在我的macOS上安装postgre:Yosemite 10.10.2

首先,我这样做是因为我试图在不支持sqlite的Heroku上部署我的应用程序,所以我做了以下内容:

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()? 我在这里错过了什么吗?

提前致谢=)

1 个答案:

答案 0 :(得分:0)

虽然你基本上没有使用"生产"在您的本地计算机上,您仍然需要在计算机上安装postgres才能使一切正常运行。根据您的日志,您似乎没有正确安装postgres。

我建议使用homebrew进行安装:

brew install postgres

在通过自制软件安装postgres后安装pg gem时,不应该出现此错误。

如果您使用其他方法进行安装,则可能需要在安装pg gem时添加一些参数。以下是一些参考文献:

Installing PostgreSQL gem under Ubuntu and Mac

Can't find the PostgreSQL client library (libpq)