新手问题 gem install pg 遇到的问题

drine · 2015年08月24日 · 最后由 drine 回复于 2015年08月24日 · 2365 次阅读

ubuntu 下 下面是报错信息。还有个问题,在哪看 heroku 支持的各种包的版本啊?

Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.

/home/coldfarmer/.rvm/rubies/ruby-2.2.0/bin/ruby -r ./siteconf20150823-3468-1op4obf.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

找到个解决方法:先安装 postgresql。一会试试再看

先:

sudo apt-get install libpq-dev

https://ruby-china.org/markdown 另外,请不要重复发帖,基于原帖修改,然后 @ 管理员

4 楼 已删除

apt-get postguisql 后 gem install pg 还是失败,一样的报错信息。 sudo apt-get install libpg-dev 后的报错信息:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package libpg-dev

@drine 先:

sudo apt-get update

#6 楼 @mueven 刚也看到了叫先 update 解决问题...但我试过了 apt-get update 后,并没有什么卵用...所有报错没有任何改变。

问题解决了,

bundle config build.pg --with-pg-config=/usr/pgsql-9.1/bin/pg_config

sudo apt-get install libpq-dev

成功,pg 也装上了。 参考:http://stackoverflow.com/questions/9234960/gem-install-pg-with-pg-config-works-bundle-fails

#8 楼 @drine 是怎么把 pg 装到那个位置的?

#9 楼 @rei 我的 pg 没在那个位置,只是执行后安装就没有一点问题了

需要 登录 后方可回复, 如果你还没有账号请 注册新账号