2012-02-10 114 views
59

WhenI运行(作为root)创业板安装PG --with-PG-配置工程,束失败

gem install pg -v '0.12.0' -- --with-pg-config=/usr/pgsql-9.1/bin/pg_config 

我得到以下输出:

#-> gem instal pg -v '0.12.0' -- --with-pg-config=/usr/pgsql-9.1/bin/pg_config 
Building native extensions. This could take a while... 
Successfully installed pg-0.12.0 
1 gem installed 
Installing ri documentation for pg-0.12.0... 
Installing RDoc documentation for pg-0.12.0... 
#-> 

当我运行捆绑安装:

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

    /usr/local/rvm/rubies/ruby-1.9.2-p290/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=/usr/local/rvm/rubies/ruby-1.9.2-p290/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 /var/www/simpletrac/vendor/cache/ruby/1.9.1/gems/pg- 0.12.0 for inspection. 
Results logged to /var/www/simpletrac/vendor/cache/ruby/1.9.1/gems/pg-0.12.0/ext/gem_make.out 
An error occured while installing pg (0.12.0), and Bundler cannot continue. 
Make sure that `gem install pg -v '0.12.0'` succeeds before bundling. 

我有libpq-fe.h安装在/usr/pgsql-9.1/include/libpq-fe.h。所以,我试过

gem install pg -v '0.12.0' -- --with-pg-config=/usr/pgsql-9.1/bin/pg_config --with-pg-lib=/usr/pgsql-9.1/include/libpq-fe.h but still no go. 

任何帮助将不胜感激。

另外,我已经安装了postgresql91-devel和ruby-devel。运行CentOS 6.

回答

148

您是否在运行前试过运行过这个bundle install

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

http://bundler.io/v1.3/bundle_config.html

+8

之后你是一个魔术师。非常感谢! – YuKagi 2012-02-10 21:40:34

+0

如果您使用的是MacOS + MacPorts,请参阅Lester的解决方案文章。 – Matthias 2012-08-07 09:41:06

+0

我有同样的错误,但我正在使用mysql数据库。什么将命令请求? – 2013-03-20 13:26:57

16

如果有人使用的MacPorts安装Postgres的,并具有发现他们pg_config问题,试试这个:

bundle config build.pg --with-pg-config=/opt/local/lib/postgresql91/bin/pg_config 

我希望这可以帮助别人节省一些时间。干杯!

+0

你是一个救星!!!! – 2012-05-22 17:25:42

+0

这为我修好了,干杯! – Matthias 2012-08-07 09:40:23

4

如果您安装了pg_config但它不在任何路径中,则可能会出现此错误。您可以将它添加到您的〜/ .bashrc中的PATH env中。

例如。

export PATH=${PATH}:/usr/pgsql-9.2/bin 
+0

这可能是源代码而不是包管理器安装的结果吗?无论如何为我工作 - 只是好奇我为什么遇到问题。 – FantasticSponge 2014-06-30 14:20:38

3

我不得不这样做是为了解决在OS X矿:

export PATH=/opt/local/lib/postgresql84/bin/:$PATH 

我不得不这样做尽管我已经在我的道路了这一点:

[[email protected] ~] which psql84 
/opt/local/bin/psql84 

[[email protected] ~] ls -altrh /opt/local/bin/psql84 
lrwxr-xr-x 1 root admin 36B Dec 7 02:15 /opt/local/bin/psql84 -> /opt/local/lib/postgresql84/bin/psql 

我希望能帮助另一位Mac用户解决这个问题。

+0

这一个为我工作,谢谢。 – holms 2013-11-09 01:21:19

+0

谢谢我在Mac Yosemite上测试了这个解决方案。 – newguy 2016-02-05 14:12:40

1

试试这个:

yum install libpqxx-devel 

它与Postgr9.2。

3

Postgres gem找不到Postgres配置文件。你需要告诉它它在哪里。在我看来,最令人愉快的解决方案是跳过Brew和MacPorts,并使用Postgres应用程序。从这里下载并安装:

http://postgresapp.com/

现在添加bin文件夹到您的路径:

PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH" 

您也不妨将它添加到您的〜/ .bash_profile中

现在安装宝石:

gem install pg 

它应该顺利。

4

我在Mac和我使用自制软件,所以要解决这个问题,我刚安装PostgreSQL用于酿造:

brew install postgresql 

再装宝石。

0
gem install pg -v '0.17.1' 

对我来说算过了。

2

我正在使用Arch Linux,并且遇到类似的问题。使用sudo pacman -S libpqxx和reran然后安装了pg gem,然后再次运行bundle install,这次它终于奏效了!

+0

我也在使用Arch Linux,这解决了我的问题! – 2015-12-04 23:17:29

+0

2016,postgresql 9.5和pg 0.18.4似乎没有提到的解决方案(我也使用arch linux)。 – 2016-02-21 20:33:46

1

link使用建议:

gem install pg --pre 

我不能让pg gem安装好几天,但这种方法终于为我工作。希望这会有所帮助。

9

如果你不知道从哪里你pg_config是,假设你是在Linux或Mac,你可以运行下面的命令:

which pg_config 

这将返回==>/usr/pgsql-9.1/bin/pg_config

现在使用这个路径

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

现在完成bundle install

3

复制粘贴&:

bundle config build.pg --with-pg-config=`which pg_config` && bundle 

详情:

更多信息请访问:

你应该做的是确保“pg_config”工具自带的Postgres是在路径的第一件事。如果不是,或者您的路径中第一个不是使用您要构建的Postgres安装的路径,则可以使用-with-pg-config选项指定路径。

来源:https://github.com/ged/ruby-pg/blob/1f274f68c16f1af1c642db1b9d3d28aef169dc84/ext/extconf.rb#L27

0

确保你已经安装了postgress。如果不是先安装它。以终端为例。

brew install postgresql 

该运行

bundle install