About me

说啥呢 欢迎欢迎,热烈欢迎。。

rails gem install pg

August 07, 2013

一开始直接装是这个错:

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.
然后查了好多解决方法都不行,看错误应该是需要安装依赖,去 http://www.postgresql.org/ 官网看了下安装过程,虽然它有安装包下载,不过我还是喜欢添加源

sudo add-apt-repository ppa:pitti/postgresql

sudo apt-get update

然后我再安装,错误变了:

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.
这个又在网上找,各种试,在 http://blog.sina.com.cn/s/blog_671ada9701011ksr.html 找到了方法

sudo apt-get install libpq-dev

这个之后 再运行

gem install pg -v '0.16.0'

版本号可加可不加。 OK,安装完成。