gem install pg |错误:未声明“ PQERRORS_SQLSTATE”

问题描述

我正在使用rbenv在openSuse Leap中工作。从Leap 15.1升级到15.2后,我遇到了问题。我无法使'gem install pg'。

复制:

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

    current directory: /home/alex/.rbenv/versions/2.6.6/lib64/ruby/gems/2.6.0/gems/pg-1.2.3/ext
/home/alex/.rbenv/versions/2.6.6/bin/ruby -I /home/alex/.rbenv/versions/2.6.6/lib64/ruby/2.6.0 -r ./siteconf20200827-12823-54e7ke.rb extcon
f.rb
checking for pg_config... no
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.
---



find / -name "pg_config" -print
/usr/lib/postgresql10/bin/pg_config


gem install pg -- --with-pg-config=/usr/lib/postgresql10/bin/pg_config 
Building native extensions with: '--with-pg-config=/usr/lib/postgresql10/bin/pg_config'
This Could take a while...
ERROR:  Error installing pg:
        ERROR: Failed to build gem native extension.


    current directory: /home/alex/.rbenv/versions/2.6.6/lib64/ruby/gems/2.6.0/gems/pg-1.2.3/ext
/home/alex/.rbenv/versions/2.6.6/bin/ruby -I /home/alex/.rbenv/versions/2.6.6/lib64/ruby/2.6.0 -r ./siteconf20200827-12620-silryo.rb extconf.rb --with-pg-config\=/usr/lib/postgresql10/bin/pg_config
Using config values from /usr/lib/postgresql10/bin/pg_config
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... yes
checking for PQsetSingleRowMode()... yes
checking for PQconninfo()... yes
checking for PQsslAttribute()... yes
checking for PQresultVerboseErrorMessage()... yes
checking for PQencryptPasswordConn()... yes
checking for PQresultMemorySize()... yes
checking for timegm()... yes
checking for rb_gc_adjust_memory_usage()... yes
checking for unistd.h... yes
checking for inttypes.h... yes
checking for C99 variable length arrays... yes
creating extconf.h
creating Makefile


current directory: /home/alex/.rbenv/versions/2.6.6/lib64/ruby/gems/2.6.0/gems/pg-1.2.3/ext
make "DESTDIR=" clean


current directory: /home/alex/.rbenv/versions/2.6.6/lib64/ruby/gems/2.6.0/gems/pg-1.2.3/ext
make "DESTDIR="
compiling gvl_wrappers.c
compiling pg.c
In file included from /home/alex/.rbenv/versions/2.6.6/include/ruby-2.6.0/ruby.h:33:0,from pg.h:20,from pg.c:49:
pg.c: In function ‘Init_pg_ext’:
pg.c:470:64: error: ‘PQERRORS_sqlSTATE’ undeclared (first use in this function); did you mean ‘PQERRORS_TERSE’?
  rb_define_const(rb_mPGconstants,"PQERRORS_sqlSTATE",INT2FIX(PQERRORS_sqlSTATE));
                                                                ^
/home/alex/.rbenv/versions/2.6.6/include/ruby-2.6.0/ruby/ruby.h:261:33: note: in deFinition of macro ‘RB_INT2FIX’
 #define RB_INT2FIX(i) (((VALUE)(i))<<1 | RUBY_FIxnuM_FLAG)
                                 ^
pg.c:470:56: note: in expansion of macro ‘INT2FIX’
  rb_define_const(rb_mPGconstants,INT2FIX(PQERRORS_sqlSTATE));
                                                        ^~~~~~~
pg.c:470:64: note: each undeclared identifier is reported only once for each function it appears in
  rb_define_const(rb_mPGconstants,INT2FIX(PQERRORS_sqlSTATE));
                                                        ^~~~~~~
pg.c: At top level:
cc1: warning: unrecognized command line option ‘-Wno-self-assign’
cc1: warning: unrecognized command line option ‘-Wno-parentheses-equality’
cc1: warning: unrecognized command line option ‘-Wno-constant-logical-operand’
cc1: warning: unrecognized command line option ‘-Wno-cast-function-type’
make: *** [Makefile:245: pg.o] Ошибка 1


make Failed,exit code 2


Gem files will remain installed in /home/alex/.rbenv/versions/2.6.6/lib64/ruby/gems/2.6.0/gems/pg-1.2.3 for inspection.
Results logged to /home/alex/.rbenv/versions/2.6.6/lib64/ruby/gems/2.6.0/extensions/x86_64-linux/2.6.0/pg-1.2.3/gem_make.out

OpenSuse支持论坛建议我报告Bugzilla上的错误

'看起来尽管满足了依赖性,但是由于支持方法的更改,可能会出现上游编译错误代码识别出错误,然后尝试自行解决(显然在代码中已经进行了一些错误检查和修复,也许以前已经发生过此类错误)。这种错误不太可能由最终用户解决。'

但这不能解决问题,请take a look。 有任何想法吗?帮助将非常有帮助。

UPD

LC_ALL=C sudo zypper in postgresql postgresql-server postgresql-contrib
[sudo] password for root:
Loading repository data...
Reading installed packages...
'postgresql' is already installed.
No update candidate for 'postgresql-12.0.1-lp152.5.5.noarch'. The highest available version is already installed.
'postgresql-server' is already installed.
No update candidate for 'postgresql-server-12.0.1-lp152.5.5.noarch'. The highest available version is already installed.
'postgresql-contrib' is already installed.
No update candidate for 'postgresql-contrib-12.0.1-lp152.5.5.noarch'. The highest available version is already installed.
Resolving package dependencies...

nothing to do.

解决方法

不确定Leap,但是在Tumbleweed下,我通过删除postgresql10-devel并安装了postgresql12-devel和postgresql12-server-devel解决了完全相同的问题。