无法在 CentOS Linux 版本 7.6.1810 上安装 pg gem

无法在 CentOS Linux 版本 7.6.1810 上安装 pg gem
ruby --version ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux]

gem --version 3.3.7

PostgreSQL 9.2.24 on x86_64-redhat-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit 当我跑步时

env ARCHFLAGS="-arch x86_64" gem install pg

根据,我得到

Building native extensions. This could take a while...
ERROR:  Error installing pg:
        ERROR: Failed to build gem native extension.

    current directory: /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/pg-1.3.5/ext
/root/.rbenv/versions/3.1.2/bin/ruby -I /root/.rbenv/versions/3.1.2/lib/ruby/3.1.0 -r ./siteconf20220601-102563-hl61l1.rb extconf.rb
Calling libpq with GVL unlocked
checking for pg_config... yes
Using config values from /bin/pg_config
Using libpq from /usr/lib64
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*****************************************************************************

Unable to find PostgreSQL client library.

Please install libpq or postgresql client package like so:
  sudo apt install libpq-dev
  sudo yum install postgresql-devel
  sudo zypper in postgresql-devel
  sudo pacman -S postgresql-libs

or try again with:
  gem install pg -- --with-pg-config=/path/to/pg_config

or set library paths manually with:
  gem install pg -- --with-pg-include=/path/to/libpq-fe.h/ --with-pg-lib=/path/to/libpq.so/

*** 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
        --without-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=/root/.rbenv/versions/3.1.2/bin/$(RUBY_BASE_NAME)
        --with-pg
        --without-pg
        --enable-gvl-unlock
        --disable-gvl-unlock
        --enable-windows-cross
        --disable-windows-cross
        --with-pg-config
        --without-pg-config
        --with-pg_config
        --without-pg_config
        --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-pq-dir
        --without-pq-dir
        --with-pq-include
        --without-pq-include=${pq-dir}/include
        --with-pq-lib
        --without-pq-lib=${pq-dir}/lib
        --with-pqlib
        --without-pqlib
        --with-libpq-dir
        --without-libpq-dir
        --with-libpq-include
        --without-libpq-include=${libpq-dir}/include
        --with-libpq-lib
        --without-libpq-lib=${libpq-dir}/lib
        --with-libpqlib
        --without-libpqlib
        --with-ms/libpq-dir
        --without-ms/libpq-dir
        --with-ms/libpq-include
        --without-ms/libpq-include=${ms/libpq-dir}/include
        --with-ms/libpq-lib
        --without-ms/libpq-lib=${ms/libpq-dir}/lib
        --with-ms/libpqlib
        --without-ms/libpqlib

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/extensions/x86_64-linux/3.1.0/pg-1.3.5/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/pg-1.3.5 for inspection.
Results logged to /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/extensions/x86_64-linux/3.1.0/pg-1.3.5/gem_make.out

我已经做好了sudo yum install postgresql-devel

Package postgresql-devel-9.2.24-7.el7_9.x86_64 already installed and latest version
Nothing to do

curl -I https://rubygems.org/specs.4.8.gz

HTTP/1.1 200 Connected

HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 4701495
...

我也做过yum groupinstall 'Development Tools'

我应该怎么做才能安装 pg gem?

答案1

就我而言(Centos 7)需要pg_config,所以我安装了开发包:

yum install postgresql-devel

然后我必须将其添加到路径中

export PATH=$PATH:/usr/pgsql-12/bin

我使用的是 pgsql 12,您可能需要指向您的版本文件夹。

相关内容