无法在 Windows 上安装 pg gem

fai*_*ars 1 ruby windows postgresql rubygems pg

我正在尝试在我的项目中安装 pg gem,但是当我运行 gem install pg 或运行 bundle install 时出现以下错误:

ERROR:  Error installing pg:
    ERROR: Failed to build gem native extension.

current directory: /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/pg-1.1.4/ext
/home/ec2-user/.rvm/rubies/ruby-2.6.3/bin/ruby -I /home/ec2- 
user/.rvm/rubies/ruby-2.6.3/lib/ruby/site_ruby/2.6.0 -r 
./siteconf20191103-5491-ro2ye0.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/ec2-user/.rvm/rubies/ruby-2.6.3/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/ec2-user/.rvm/gems/ruby-2.6.3/extensions/x86_64-linux/2.6.0/pg- 
1.1.4/mkmf.log

extconf failed, exit code 1
Run Code Online (Sandbox Code Playgroud)

如您所见,我使用的是 Ruby 版本 2.6.3,并且使用的是 Windows。我正在尝试安装 pg gem,以便可以连接到数据库。我对这一切都很陌生,所以任何帮助将不胜感激

Cas*_*per 5

你缺少pg_config,这意味着很可能没有安装 pg 开发包。

apt install libpq-dev
Run Code Online (Sandbox Code Playgroud)