pg gem安装失败,无法找到libpq-fe.h头文件
问题描述:
每当我在我的VPS(CentOS Linux版本7.0.1406(Core))上运行bundle install
时,安装pg gem时出现错误。pg gem安装失败,无法找到libpq-fe.h头文件
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.
我可以安装pg standalone:gem install pg -- --with-pg-config=/usr/pgsql-9.4/bin/pg_config
并且问题已解决。
因此,我添加了一个capistrano任务,为部署创建一个./bundle/config,并使用在我的VPS上设置pg_config路径的build.pg密钥。在Capistrano config/deploy.rb
这被调用before bundler:install
。
desc "Create bundle config"
task :prepare_bundle_config do
on roles(:app) do
within release_path do
execute :bundle, 'config build.pg --with-pg-config=/usr/pgsql-9.4/bin/pg_config --local'
end
end
end
我已经安装了必要的软件包:
postgresql94-server.x86_64
postgresql94-devel.x86_64
postgresql94-libs.x86_64
libpqxx.x86_64
libpqxx-devel.x86_64
这里是Capistrano的*我已经安装
bundle list | grep capistrano
* capistrano (3.3.5)
* capistrano-bundler (1.1.4)
* capistrano-rails (1.1.2)
* capistrano-rbenv (2.0.3)
* capistrano-stats (1.1.1)
缺少什么我在这里跟打捆成功安装皮克宝石?如果您需要任何其他信息,请留下评论,我会更新这篇文章。
答
postgres二进制文件不在路径中。将它们符号链接到路径中的目录中,您应该很好:ln -s /usr/pgsql-9.4/bin/p* /usr/local/bin
。
你建立了postgres还是从yum安装?
答
我发现如果我编译带源代码的pgsql,并且PATH ENV没有与pgsql/bin配合,就会发生这种情况。你可以试试这个。
您的自定义任务能否成功独立运行通过Capistrano? Capistrano有什么输出? – JoePasq 2015-03-10 21:56:33
感谢您的回应:以下是capistrano输出的一个要点(带调试)https://gist.github.com/whargrove/03ff94d1b6e7648030ed – whargrove 2015-03-11 02:24:38
:prepare_bundle_config不能独立运行,因为它使用release_path,所以它只能用在部署任务期间。 – whargrove 2015-03-11 02:26:13