Ruby - gem インストールページ |エラー: 「PQERRORS_SQLSTATE」が宣言されていません

okwaves2024-01-25  7

私は openSuse Leap で rbenv を使用して作業しています。 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, "PQERRORS_SQLSTATE", 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, "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, "PQERRORS_SQLSTATE", 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 でバグを報告することを推奨しました。

'依存関係は満たされていますが、サポートされているメソッドの変更が原因でアップストリームのコンパイル エラーが発生しているようです。コードはエラーを特定し、独自に解決しようとしました (どうやら、コードにはすでにエラー チェックと修正が含まれているようです。おそらく、このようなエラーが以前にも発生した可能性があります)。この種のエラーは、エンド ユーザーが解決できる可能性は高くありません。」

しかし、これでは問題は解決しませんでした。見てください。 何か案は?助けていただけると大変助かります。

更新

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.

Postgres ライブラリをインストールする必要があります。ここを参照してください: en.opensuse.org/SDB:PostgreSQL

– もう一つ

2020 年 9 月 3 日 21:40

@anothermh、どのような種類のライブラリですか??

– アレックス

2020 年 9 月 3 日 22:08

Postgres ライブラリ。上記のリンクを参照して、それらのパッケージをインストールし、再試行してください。

– もう一つ

2020 年 9 月 3 日 22:13

申し訳ありませんが、理解できません。 postgresql-develについて話しているのですか?問題は解決しません。インストールするライブラリに名前を付けてください。

– アレックス

2020 年 9 月 3 日 22:38

あなたはショーRuby pg リポジトリ: github.com/ged/ruby-pg/issues で問題として報告してください。

– キャスパー

2020 年 9 月 5 日 0:15



------------------------

Leap についてはわかりませんが、Tumbleweed では、postgresql10-devel を削除し、postgresql12-devel と postgresql12-server-devel の両方をインストールすることで、まったく同じ問題を解決しました。

3

SO へようこそ!ツアーをお読みください。良い回答を書くにはどうすればよいですか?

– トメル・シェタ

2020 年 10 月 12 日 8:48

まったく同じ問題が発生し、postgresql13-server-devel の zypper で解決しました。

– オレグ・アントニアン

2021 年 5 月 9 日 13:58

私は Leap を使用していますが、これで問題も解決しました。

– マチュー J.

2022 年 6 月 17 日 7:49

総合生活情報サイト - OKWAVES
総合生活情報サイト - OKWAVES
生活総合情報サイトokwaves(オールアバウト)。その道のプロ(専門家)が、日常生活をより豊かに快適にするノウハウから業界の最新動向、読み物コラムまで、多彩なコンテンツを発信。