如何在SUSE 15.1上安装pg gem



为了实现Rails 5.2.4,我刚刚在一个新的SUSE 15.1服务器上安装了PostgreSQL 13,然后安装了Ruby 2.6.6,现在我正在尝试安装PostgreSQL客户端gem:pg 1.2.3版本。

我首先尝试运行gem install pg,它声称缺少文件pg_configlibpq fe.h:

Building native extensions. This could take a while...
ERROR:  Error installing pg:
ERROR: Failed to build gem native extension.
current directory: /home/a80838986/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/pg-1.2.3/ext
/home/a80838986/.rbenv/versions/2.6.6/bin/ruby -I /home/a80838986/.rbenv/versions/2.6.6/lib/ruby/2.6.0 -r ./siteconf20201103-26887-19gz250.rb extconf.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.  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=/home/a80838986/.rbenv/versions/2.6.6/bin/$(RUBY_BASE_NAME)
--with-pg
--without-pg
--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
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/home/a80838986/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/extensions/x86_64-linux/2.6.0/pg-1.2.3/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /home/a80838986/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/pg-1.2.3 for inspection.
Results logged to /home/a80838986/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/extensions/x86_64-linux/2.6.0/pg-1.2.3/gem_make.out

在文件系统中搜索,我找到了一组可以满足gem安装要求的文件,但我找不到如何使用以下文件运行安装:

ls -l /usr/include/pgsql/                total 152
-rwxr-xr-x 1 root root   656 Oct 29 01:11 ecpg_config.h
-rwxr-xr-x 1 root root  2544 Oct 29 01:11 ecpgerrno.h
-rwxr-xr-x 1 root root  2803 Oct 29 01:11 ecpg_informix.h
-rwxr-xr-x 1 root root  2681 Oct 29 01:11 ecpglib.h
-rwxr-xr-x 1 root root  2709 Oct 29 01:11 ecpgtype.h
drwxr-xr-x 1 root root     8 Nov  3 12:25 informix
drwxr-xr-x 1 root root   102 Nov  3 12:25 internal
drwxr-xr-x 1 root root    20 Nov  3 12:25 libpq
-rwxr-xr-x 1 root root  2214 Oct 29 01:11 libpq-events.h
-rwxr-xr-x 1 root root 23338 Oct 29 01:11 libpq-fe.h
-rwxr-xr-x 1 root root   323 Oct 29 01:11 pg_config_ext.h
-rwxr-xr-x 1 root root 31970 Oct 29 01:11 pg_config.h
-rwxr-xr-x 1 root root 12877 Oct 29 01:11 pg_config_manual.h
-rwxr-xr-x 1 root root  1052 Oct 29 01:11 pg_config_os.h
-rwxr-xr-x 1 root root   797 Oct 29 01:11 pgtypes_date.h
-rwxr-xr-x 1 root root   530 Oct 29 01:11 pgtypes_error.h
-rwxr-xr-x 1 root root   222 Oct 29 01:11 pgtypes.h
-rwxr-xr-x 1 root root  1032 Oct 29 01:11 pgtypes_interval.h
-rwxr-xr-x 1 root root  2251 Oct 29 01:11 pgtypes_numeric.h
-rwxr-xr-x 1 root root   945 Oct 29 01:11 pgtypes_timestamp.h
-rwxr-xr-x 1 root root  2239 Oct 29 01:11 postgres_ext.h
-rwxr-xr-x 1 root root   838 Oct 29 01:11 sql3types.h
-rwxr-xr-x 1 root root  1283 Oct 29 01:11 sqlca.h
-rwxr-xr-x 1 root root  1575 Oct 29 01:11 sqlda-compat.h
-rwxr-xr-x 1 root root   321 Oct 29 01:11 sqlda.h
-rwxr-xr-x 1 root root   824 Oct 29 01:11 sqlda-native.h

pg_config仍然缺失,libpq fe.h存在,但是:

  • 无pg配置选项无效
  • 我不知道如何把球传给libpqfe.h

你能帮我完成这个安装吗?

我发现pg_config实用程序属于postgresql13-server-devel包。安装此软件包解决了我的问题。

最新更新