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를 사용하고 있습니다. 버전 폴더를 지정해야 할 수도 있습니다.

관련 정보