7

pg gem 很顽固,所以我无法在新计算机上加载我的应用程序。似乎有多个问题,无法找到 pg_config 然后 extconf.rb

#psql working...
psql (9.2.1)
Type "help" for help.

nd =>
\q

$ pg_config:

#adding the path to bashrc...
$ nano .bashrc

PATH=/usr/pgsql-9.2/bin:$PATH

#seems to work...
pg_config: /usr/pgsql-9.2/bin/pg_config

$ sudo gem install pg

#but i get the same errors...
Building native extensions.  This could take a while...
.......
ERROR:  Error installing pg:
        ERROR: Failed to build gem native extension.

        /usr/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.

有没有处理过这个问题的linux人?

4

4 回答 4

21

这解决了

$ yum install /usr/include/libpq-fe.h
于 2012-12-02T05:07:41.250 回答
15

对于 Fedora 20+,需要以下软件包:

sudo yum install postgresql-devel
于 2014-10-04T12:00:49.450 回答
2

对于 Fedora 30:

$sudo dnf install libpq-devel

然后:

$gem install pg

Building native extensions. This could take a while...
Successfully installed pg-1.1.4
Parsing documentation for pg-1.1.4
Installing ri documentation for pg-1.1.4
Done installing documentation for pg after 1 seconds
1 gem installed
于 2019-09-23T10:18:48.747 回答
0

~ 你好

我在我的 Rails 项目中安装 gem“pg”时遇到了同样的问题,当运行命令“bundle install”时有同样的错误,在我的情况下,partiuclar 解决它如下:

我用的是 Fedora 19,我想在 Fedora 17 中可以用同样的方法解决:

我使用以下教程安装了 Postgres:

然后,我在 ~/.bashrc 中添加了下一行来解决 pg_config 的问题:

  • PATH = / usr/pgsql-9.2/bin: $ PATH

最后为了解决 libpq-fe.h 的问题,我安装了 postgresql-devel,如下所示:

  • # yum install postgresql92-devel

最后在我的 Rails 项目中运行命令“bundle install”并且没有更多错误。

于 2013-08-29T02:31:35.043 回答