Windows 10+红宝石3.1.2-无法安装诺科吉里
我是开发的新手,只是试图将Windows 10 PC设置为Rails开发。我发现一个教程似乎很清楚,可以实现在这里。
我能够安装Ruby 3.1.2,然后将其解压缩到永久文件夹。我将其添加到路径上,然后继续构建工具。我从他们的网站下载了MSYS2并安装了MSYS2,然后设置pacman
,然后rubyinstaller2-安装MSYS2和MINGW开发工具链。我不愿安装C依赖C的宝石,并且能够安装sqlite3
last:
ridk exec pacman -S mingw-w64-x86_64-sqlite3
gem install sqlite3 --platform ruby
然后继续安装nokogiri
gem:
ridk exec pacman -S mingw-w64-x86_64-libxslt
gem install nokogiri --platform ruby -- --use-system-libraries
这个最终的GEM安装线是我失败的地方。我在大多数情况下都是非常新的,并且接近尝试安装WSL或虚拟机,但是我认为尝试进行故障排除并找到解决方案是明智的。
C:\WINDOWS\system32>gem install nokogiri --platform ruby -- --use-system-libraries
Temporarily enhancing PATH for MSYS/MINGW...
Building native extensions with: '--use-system-libraries'
This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
current directory: C:/Dev/Dependencies/Ruby/rubyinstaller-3.1.2-1-x64/lib/ruby/gems/3.1.0/gems/nokogiri-1.13.6/ext/nokogiri
C:/Dev/Dependencies/Ruby/rubyinstaller-3.1.2-1-x64/bin/ruby.exe -I C:/Dev/Dependencies/Ruby/rubyinstaller-3.1.2-1-x64/lib/ruby/site_ruby/3.1.0 -r ./siteconf20220511-16300-lhgizk.rb extconf.rb --use-system-libraries
checking for whether -std=c99 is accepted as CFLAGS... yes
checking for whether -Wno-declaration-after-statement is accepted as CFLAGS... yes
checking for whether -g is accepted as CFLAGS... yes
checking for whether -Winline is accepted as CFLAGS... yes
checking for whether -Wmissing-noreturn is accepted as CFLAGS... yes
checking for whether "-Idummypath" is accepted as CPPFLAGS... yes
Building nokogiri using system libraries.
checking for gzdopen() in -lz... yes
checking for xmlParseDoc() in -lxml2... no
checking for xmlParseDoc() in -llibxml2... no
checking for libxml-2.0 using `pkg_config`... no
Please install either the `pkg-config` utility or the `pkg-config` rubygem.
checking for xmlParseDoc() in -lxml2... no
checking for xmlParseDoc() in -llibxml2... no
-----
extconf.rb:285:in `ensure_package_configuration'
extconf.rb:648:in `<main>'
xml2 is missing. Please locate mkmf.log to investigate how it is failing.
-----
*** 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=C:/Dev/Dependencies/Ruby/rubyinstaller-3.1.2-1-x64/bin/$(RUBY_BASE_NAME)
--help
--clean
--prevent-strip
--enable-system-libraries
--disable-system-libraries
--use-system-libraries
--enable-system-libraries
--disable-system-libraries
--use-system-libraries
--with-zlib-dir
--without-zlib-dir
--with-zlib-include
--without-zlib-include=${zlib-dir}/include
--with-zlib-lib
--without-zlib-lib=${zlib-dir}/lib
--with-z-dir
--without-z-dir
--with-z-include
--without-z-include=${z-dir}/include
--with-z-lib
--without-z-lib=${z-dir}/lib
--with-zlib
--without-zlib
--with-xml2-dir
--without-xml2-dir
--with-xml2-include
--without-xml2-include=${xml2-dir}/include
--with-xml2-lib
--without-xml2-lib=${xml2-dir}/lib
--with-xml2lib
--without-xml2lib
--with-libxml2-dir
--without-libxml2-dir
--with-libxml2-include
--without-libxml2-include=${libxml2-dir}/include
--with-libxml2-lib
--without-libxml2-lib=${libxml2-dir}/lib
--with-libxml2lib
--without-libxml2lib
--with-libxml-2.0-dir
--without-libxml-2.0-dir
--with-libxml-2.0-include
--without-libxml-2.0-include=${libxml-2.0-dir}/include
--with-libxml-2.0-lib
--without-libxml-2.0-lib=${libxml-2.0-dir}/lib
--with-libxml-2.0-config
--without-libxml-2.0-config
--with-pkg-config
--without-pkg-config
--with-xml2lib
--without-xml2lib
--with-libxml2lib
--without-libxml2lib
To see why this extension failed to compile, please check the mkmf.log which can be found here:
C:/Dev/Dependencies/Ruby/rubyinstaller-3.1.2-1-x64/lib/ruby/gems/3.1.0/extensions/x64-mingw-ucrt/3.1.0/nokogiri-1.13.6/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in C:/Dev/Dependencies/Ruby/rubyinstaller-3.1.2-1-x64/lib/ruby/gems/3.1.0/gems/nokogiri-1.13.6 for inspection.
Results logged to C:/Dev/Dependencies/Ruby/rubyinstaller-3.1.2-1-x64/lib/ruby/gems/3.1.0/extensions/x64-mingw-ucrt/3.1.0/nokogiri-1.13.6/gem_make.out
C:\WINDOWS\system32>
因此,当我阅读有关“请安装pkg-config rubygem”的点时,我查看了如何做,并尝试在MSYS2中安装,这似乎是这样做的。
I am quite new to development and just trying to set my Windows 10 PC up for Rails development. I found a tutorial that seemed quite clear and achievable here.
I was able to install Ruby 3.1.2 and unzipped it to a permanent folder. I added it to path, and then moved on to build tools. I downloaded MSYS2 from their site and installed, then set up pacman
, then RubyInstaller2--installing the MSYS2 and MINGW development toolchain. I was down to installing the C-dependent gems and was able to install sqlite3
using:
ridk exec pacman -S mingw-w64-x86_64-sqlite3
gem install sqlite3 --platform ruby
And went on to install nokogiri
gem:
ridk exec pacman -S mingw-w64-x86_64-libxslt
gem install nokogiri --platform ruby -- --use-system-libraries
This final gem install line is where I have failed. I am very new at most of this and am close to trying to install WSL or a virtual machine, but I thought it was sensible to try and troubleshoot and find the solution.
C:\WINDOWS\system32>gem install nokogiri --platform ruby -- --use-system-libraries
Temporarily enhancing PATH for MSYS/MINGW...
Building native extensions with: '--use-system-libraries'
This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
current directory: C:/Dev/Dependencies/Ruby/rubyinstaller-3.1.2-1-x64/lib/ruby/gems/3.1.0/gems/nokogiri-1.13.6/ext/nokogiri
C:/Dev/Dependencies/Ruby/rubyinstaller-3.1.2-1-x64/bin/ruby.exe -I C:/Dev/Dependencies/Ruby/rubyinstaller-3.1.2-1-x64/lib/ruby/site_ruby/3.1.0 -r ./siteconf20220511-16300-lhgizk.rb extconf.rb --use-system-libraries
checking for whether -std=c99 is accepted as CFLAGS... yes
checking for whether -Wno-declaration-after-statement is accepted as CFLAGS... yes
checking for whether -g is accepted as CFLAGS... yes
checking for whether -Winline is accepted as CFLAGS... yes
checking for whether -Wmissing-noreturn is accepted as CFLAGS... yes
checking for whether "-Idummypath" is accepted as CPPFLAGS... yes
Building nokogiri using system libraries.
checking for gzdopen() in -lz... yes
checking for xmlParseDoc() in -lxml2... no
checking for xmlParseDoc() in -llibxml2... no
checking for libxml-2.0 using `pkg_config`... no
Please install either the `pkg-config` utility or the `pkg-config` rubygem.
checking for xmlParseDoc() in -lxml2... no
checking for xmlParseDoc() in -llibxml2... no
-----
extconf.rb:285:in `ensure_package_configuration'
extconf.rb:648:in `<main>'
xml2 is missing. Please locate mkmf.log to investigate how it is failing.
-----
*** 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=C:/Dev/Dependencies/Ruby/rubyinstaller-3.1.2-1-x64/bin/$(RUBY_BASE_NAME)
--help
--clean
--prevent-strip
--enable-system-libraries
--disable-system-libraries
--use-system-libraries
--enable-system-libraries
--disable-system-libraries
--use-system-libraries
--with-zlib-dir
--without-zlib-dir
--with-zlib-include
--without-zlib-include=${zlib-dir}/include
--with-zlib-lib
--without-zlib-lib=${zlib-dir}/lib
--with-z-dir
--without-z-dir
--with-z-include
--without-z-include=${z-dir}/include
--with-z-lib
--without-z-lib=${z-dir}/lib
--with-zlib
--without-zlib
--with-xml2-dir
--without-xml2-dir
--with-xml2-include
--without-xml2-include=${xml2-dir}/include
--with-xml2-lib
--without-xml2-lib=${xml2-dir}/lib
--with-xml2lib
--without-xml2lib
--with-libxml2-dir
--without-libxml2-dir
--with-libxml2-include
--without-libxml2-include=${libxml2-dir}/include
--with-libxml2-lib
--without-libxml2-lib=${libxml2-dir}/lib
--with-libxml2lib
--without-libxml2lib
--with-libxml-2.0-dir
--without-libxml-2.0-dir
--with-libxml-2.0-include
--without-libxml-2.0-include=${libxml-2.0-dir}/include
--with-libxml-2.0-lib
--without-libxml-2.0-lib=${libxml-2.0-dir}/lib
--with-libxml-2.0-config
--without-libxml-2.0-config
--with-pkg-config
--without-pkg-config
--with-xml2lib
--without-xml2lib
--with-libxml2lib
--without-libxml2lib
To see why this extension failed to compile, please check the mkmf.log which can be found here:
C:/Dev/Dependencies/Ruby/rubyinstaller-3.1.2-1-x64/lib/ruby/gems/3.1.0/extensions/x64-mingw-ucrt/3.1.0/nokogiri-1.13.6/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in C:/Dev/Dependencies/Ruby/rubyinstaller-3.1.2-1-x64/lib/ruby/gems/3.1.0/gems/nokogiri-1.13.6 for inspection.
Results logged to C:/Dev/Dependencies/Ruby/rubyinstaller-3.1.2-1-x64/lib/ruby/gems/3.1.0/extensions/x64-mingw-ucrt/3.1.0/nokogiri-1.13.6/gem_make.out
C:\WINDOWS\system32>
So, when I read the bit about "please install the pkg-config rubygem", I looked up how to do it and tried to install in MSYS2, which it appeared to do.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Windows并不是Rails的最佳选择,它将有很多问题,并且一切变得更加复杂,请看到此在窗户上运行红宝石/导轨的限制
Linux强烈推荐
您可以使用双启动或WSL都可以
windows is not really the best option with rails there will be a lot of issues and everything gets more complicated see this Limitations in running Ruby/Rails on windows
Linux is highly recommend
you can use dual-booting or WSL either is fine
我一个小时前就遇到了这件事,在Windows 11上安装了新的Mingw64。
安装这些软件包后
nokogiri
成功安装了(已构建)。此外,我必须将Ruby Gem安装位置添加到我的路径中才能运行可执行的Ruby Gems :
〜/.local/.local/.local/share/share/gem/ruby/3.1.0/ bin
。您的可执行性Ruby Gem位置可能会根据您安装的Ruby版本而有所不同。
值得注意的区别:
您正在运行Windows 11时在Windows 10上运行。
您正在使用Ruby 3.1.2,而MingW64在我的系统上安装了3.1.3p185版本。
附加说明:
为了完整,安装mingw64后,我还安装了
ruby
和git
pacman -s -pacman -s ruby git解决它可能是不必要的。
nokogiri
由我要自定义的jekyll主题使用。Nokogiri
是作为引导主题的一部分安装的,但我尝试了您的命令行,它也成功安装了GEM。 (首先卸载,用您的命令行重新安装。)最终注意:
根据我的经验,Linux比Windows对Ruby(开发或运行)的效果要好得多。我之所以追求这一点,是因为我在磁盘空间上很低,而WSL2会消耗最后一个。我强烈建议任何人使用WSL2如果是可行的选择。否则,当Ruby依赖性需要构建本机代码时,您将可以解密隐秘的C/C ++构建。
I just ran into this an hour ago with a fresh MINGW64 install on Windows 11.
I resolved it by installing the following set of packages using this script:
After installing those packages
nokogiri
successfully installed (built).Additionally, I had to add the ruby gem install location to my PATH in order to run executable ruby gems:
~/.local/share/gem/ruby/3.1.0/bin
.Your executable ruby gem location may vary depending on the version of ruby you have installed.
NOTABLE DIFFERENCES:
You're running on Windows 10 while I'm running Windows 11.
You were using ruby 3.1.2, while MINGW64 installed version 3.1.3p185 on my system.
ADDITIONAL NOTES:
For completeness, immediately after installing MINGW64, I also installed
ruby
andgit
withpacman -S ruby git
The list of packages used to resolve it might be more than necessary.
nokogiri
is used by a jekyll theme I want to customize. Whilenokogiri
was installed as a part of bootstrapping the theme, I tried your command line and it also successfully installed the gem. (uninstalled first, reinstalled with your command line.)FINAL NOTE:
In my experience Linux works far better for ruby (development or running) than Windows. I only pursued this because I'm low on disk space and WSL2 would consume the last of it. I highly recommend anyone use WSL2 if it's a viable option. Otherwise you'll get to decipher cryptic c/c++ build when a ruby dependency needs to build native code.
似乎最近的Windows构建 rubyinstaller 将“ ucrt”运行时用作默认值。
如果您运行
RIDK Exec Bash
您可以看到此。您没有将其安装到mingw64软件包中,而是使用以下方式:(
似乎没有区别,但我在第一行中添加了“ ucrt”)。
成功的结果:
参考:
httpps://nokogiri.org/nokogiri.org/tutorials/tutorials/installing erigys/installing_nokogiring_nokogiri.htmlw.wwwwwwwwwwwwwwwww. /a>
It seems recent windows build of RubyInstaller use "ucrt" runtime as default.
If you run
ridk exec bash
you can see this.Instead of installing it to MINGW64 packages, you shoud use this:
(It seems no difference but I added "ucrt" in the first line).
A successful result:
reference:
https://nokogiri.org/tutorials/installing_nokogiri.html#windows