centos pg gem安装失败,找不到libpq-fe.h头文件

ruoxqz4g  于 2022-11-08  发布在  其他
关注(0)|答案(4)|浏览(285)

每当我在我的VPS(CentOS Linux版本7.0.1406(核心))上运行bundle install时,我在安装pg gem时都会收到一个错误。

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单机版:gem install pg -- --with-pg-config=/usr/pgsql-9.4/bin/pg_config,问题已解决。
所以我添加了一个capistrano任务来为部署创建一个./bundle/config,并在我的VPS上设置了build.pg键和pg_config的路径。

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* gems

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)

我在这里错过了什么,以成功地安装pg与bundler?请留下评论,如果你需要任何额外的信息,我会更新这篇文章。

yqhsw0fo

yqhsw0fo1#

postgres二进制文件不在路径中。将它们符号链接到路径中的一个目录中,您应该很好:ln -s /usr/pgsql-9.4/bin/p* /usr/local/bin .
你是构建postgres还是从yum安装的?

tvokkenx

tvokkenx2#

刚刚发布了PostgreSQL 11的解决方案。如果有人在这里登陆。

sudo yum install epel-release

sudo yum install postgresql11-llvmjit

sudo yum install postgresql11-devel postgresql11-libs

然后运行

gem install pg -v '1.2.3' -- --with-pg-config=/usr/pgsql-11/bin/pg_config

就是这样

3bygqnnd

3bygqnnd3#

我发现如果我用源代码编译pgsql,而PATH ENV没有用pgsql/bin配置,就会发生这种情况。你可以试试这个。

vd8tlhqk

vd8tlhqk4#

或者,如果您使用Mac

brew link postgresql

或者在我的情况下

brew link postgresql@12

相关问题