ruby-on-rails - 为什么在安装 gem 'pg' 时出现错误?

标签 ruby-on-rails ruby-on-rails-3 postgresql

<分区>

Possible Duplicate:
Unable to install pg gem on ubuntu - Can’t find the 'libpq-fe.h header

我正在尝试将 gem pg 添加到我的本地环境中。
但它返回此错误

Errno::EACCES: Permission denied - /Users/me/.rvm/gems/ruby-1.9.3-p362/gems/pg-0.14.1/.gemtest
An error occurred while installing pg (0.14.1), and Bundler cannot continue.
Make sure that `gem install pg -v '0.14.1'` succeeds before bundling.

我该怎么办?

在那个错误消失之后,现在它返回这个错误

Installing pg (0.14.1) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

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


Gem files will remain installed in /Users/me/.rvm/gems/ruby-1.9.3-p362/gems/pg-0.14.1 for inspection.
Results logged to /Users/me/.rvm/gems/ruby-1.9.3-p362/gems/pg-0.14.1/ext/gem_make.out
An error occurred while installing pg (0.14.1), and Bundler cannot continue.
Make sure that `gem install pg -v '0.14.1'` succeeds before bundling.

最佳答案

我相信你之前在搞sudo
尝试

chown -R `whoami`:staff ~/.rvm/gems/ruby-1.9.3-p362/gems

关于ruby-on-rails - 为什么在安装 gem 'pg' 时出现错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14102691/

相关文章:

postgresql - 如何使用变量在函数中指定 COPY TO 目标?

ruby-on-rails - 用于 Rails 中配置文件完成百分比的 Gem

ruby-on-rails-3 - 博客集成到现有应用程序中

ruby-on-rails - `method_missing' : ActionMailer::Base:Class 的未定义方法 `add_delivery_method'

c# - 如何使用带有 Entity Framework Code First 的 Postgresql 的串行字段

sql - 查询中的锁定顺序(postgresql)

ruby-on-rails - ruby 关于attr_accessor、实例变量、局部变量

ruby-on-rails - 同一页面上的多个 remote_form_for 导致重复 id

javascript - Ruby on Rails javascript 无法正确加载(HTML5 模板)

ruby-on-rails - rails : Google login with omniauth