【发布时间】:2020-02-28 22:46:41
【问题描述】:
我正在尝试在我的项目中安装 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
如您所见,我使用的是 Ruby 版本 2.6.3,并且在 Windows 上。 我正在尝试安装 pg gem,以便可以连接到数据库。 我对这一切都很陌生,所以任何帮助将不胜感激
【问题讨论】:
-
这看起来不像 Windows,它看起来像 Linux。
-
@anothermh - 他可能在 Windows 上使用 linux bash:itsfoss.com/install-bash-on-windows
-
WSL 不是 Windows。
-
我使用的是 Windows,但对于这个项目,我使用的是 IDE Cloud 9 而不是 gitbash 或 Windows 命令提示符。
-
虽然您的计算机可能运行 Windows,但您运行
bundle install的环境是 Linux。确保为以后的问题指定。
标签: ruby windows postgresql rubygems pg