我正在学习Ruby on Rails并try 开发一个应用程序.

Building native extensions.  This could take a while...
ERROR:  Error installing pg:
        ERROR: Failed to build gem native extension.
 
    /home/tusharkhatiwada/.rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb
checking for pg_config... yes
Using config values from /usr/bin/pg_config
You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev
 for building a client-side application.
You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev
 for building a client-side application.
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
        --without-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=/home/tusharkhatiwada/.rvm/rubies/ruby-2.0.0-p247/bin/ruby
        --with-pg
        --without-pg
        --with-pg-config
        --without-pg-config
        --with-pg_config
        --without-pg_config
        --with-pg-dir
        --without-pg-dir
        --with-pg-include
        --without-pg-include=${pg-dir}/include
        --with-pg-lib
        --without-pg-lib=${pg-dir}/
 
 
Gem files will remain installed in /home/tusharkhatiwada/.rvm/gems/ruby-2.0.0-p247@rails4.0.0/g
ems/pg-0.17.0 for inspection.
Results logged to /home/tusharkhatiwada/.rvm/gems/ruby-2.0.0-p247@rails4.0.0/gems/pg-0.17.0/ext
/gem_make.out

在那之后,我又试了gem install pg -- --with-pg-config= '/usr/bin/pg_config'

Building native extensions with: '--with-pg-config= /usr/bin/pg_config'
This could take a while...
ERROR:  Error installing pg:
        ERROR: Failed to build gem native extension.
 
    /home/tusharkhatiwada/.rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb --with-pg-config= /us
r/bin/pg_config
Using config values from 
sh: 1: : Permission denied
sh: 1: : Permission denied
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
        --without-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=/home/tusharkhatiwada/.rvm/rubies/ruby-2.0.0-p247/bin/ruby
        --with-pg
        --without-pg
        --with-pg-config
        --with-pg-dir
        --without-pg-dir
        --with-pg-include
        --without-pg-include=${pg-dir}/include
        --with-pg-lib
        --without-pg-lib=${pg-dir}/
 
 
Gem files will remain installed in /home/tusharkhatiwada/.rvm/gems/ruby-2.0.0-p247@rails4.0.0/g
ems/pg-0.17.0 for inspection.
Results logged to /home/tusharkhatiwada/.rvm/gems/ruby-2.0.0-p247@rails4.0.0/gems/pg-0.17.0/ext
/gem_make.out

推荐答案

如果你正在使用Ubuntu,请try 安装以下lib文件

sudo apt-get install libpq-dev

然后安装pg

为我工作.

Postgresql相关问答推荐

将几个左连接合并为一个

无法从Docker迁移Golang上的两个不同服务到一个数据库'

Postgis超过2个表的查询在运行时爆炸

哪种数据类型是除法的结果?

如何使用docker/docker-compose转到本地主机?

AWS RDS Postgres 性能缓慢的数据传输

对 Postgres 进行身份验证时如何使用自定义密码哈希算法?

使用 Heroku CLI、Postgres 的 SQL 语法错误

如何将 postgres 数据库转换为 sqlite

在 postgres 中Decode解码相似的函数

PostgreSQL如何连接间隔值'2天'

在这个 Dockerfile 中创建的 Postgres 用户名/密码在哪里?

如何在 postgres 模式中列出关系

Postgres 数据库文件保存在 ubuntu 中的什么位置?

SQLAlchemy 声明式:定义触发器和索引 (Postgres 9)

删除空行

PostgreSQL - 如何在不同时区呈现日期?

使用python将数据从csv复制到postgresql

提高查询速度:simple SELECT in big postgres table

性能调优:为布尔列创建索引