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を使用しています。バージョンフォルダを指定する必要があります。

関連情報