【问题标题】:Trouble installing the pg gem [duplicate]安装 pg gem 时遇到问题 [重复]
【发布时间】:2015-07-12 02:55:02
【问题描述】:

尝试在我的 Mac 上运行我的第一个 Rails 应用程序时,我遇到了拒绝访问错误。

当我运行 bundle install 时,我得到了

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

然后我运行gem install pg -v '0.18.1' 并得到以下错误

Building native extensions.  This could take a while...
ERROR:  Error installing pg:
ERROR: Failed to build gem native extension.
/Users/foo/.rvm/rubies/ruby-2.2.1/bin/ruby -r ./siteconf20150502-79500-1qqztpf.rb 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.
Gem files will remain installed in /Users/foo/.rvm/gems/ruby-2.2.1/gems/pg-0.18.1 for inspection.
Results logged to /Users/foo/.rvm/gems/ruby-2.2.1/extensions/x86_64-darwin-14/2.2.0-static/pg-0.18.1/gem_make.out

【问题讨论】:

标签: ruby-on-rails ruby


【解决方案1】:

您是否只在生产环境中运行 PostgreSQL?在这种情况下,请确保它仅在您的 Gemfile 中分组用于生产:

group :production do 
  gem pg, '0.18.1'
end

之后,确保运行 bundle install 并声明不安装生产版 gem:

$ bundle install --without production

我希望这会有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-05
    • 2012-07-11
    • 1970-01-01
    • 2011-08-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多