gem install pg --with-pg-config可以成功,但是bundle失败。

81

当我以root身份运行时

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...
#-> 

当我运行bundle install时:
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。
18个回答

2

在Ubuntu上的一些情况

sudo apt-get install libpq-dev

在CentOS 7上

sudo yum install postgresql-devel

那么

bundle install

这对我很有帮助。

2

我正在使用Arch Linux,之前遇到了类似的问题。尝试使用sudo pacman -S libpqxx命令安装libpqxx库,然后再次安装pg gem,并重新运行bundle install命令,这一次它终于成功了!


我也使用Arch Linux,这解决了我的问题! - Francis Malloch
2016年,PostgreSQL 9.5和pg 0.18.4似乎无法与提到的解决方案配合使用(我也在使用Arch Linux)。 - Fernando Basso

1

1
这段文本的英译为:

这个链接建议使用:

gem install pg --pre

我花了几天时间都无法安装pg gem,但是这种方法最终对我起作用了。希望这对你有所帮助。


1

确保您已经安装了PostgreSQL,如果没有,请先安装它。例如,可以使用终端进行安装。

brew install postgresql

之后运行

bundle install

0
gem install pg -v '0.17.1'

做到了。

0

在OSX中,首先安装pg:

brew install postgresql

其次,执行 gem install 命令:

gem install pg --source 'https://rubygems.org/'

然后你可以运行bundle install


-1

我正在使用Mac,不想在本地安装PostgreSQL。

安装libpq并设置bundler配置对我有用。

参考链接


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接