Windows 10 + Ruby 3.1.2 --无法安装nokogiri

7vhp5slm  于 12个月前  发布在  Ruby
关注(0)|答案(1)|浏览(116)

我对开发很陌生,只是想为Rails开发设置我的Windows 10 PC。我发现了一个教程,似乎相当清晰和可实现的here
我可以安装Ruby 3.1.2并将其解压缩到一个永久文件夹。我把它添加到path中,然后继续构建工具。我从他们的网站下载了MSYS 2并安装,然后设置了pacman,然后是RubyInstaller 2--安装了MSYS 2和MINGW开发工具链。我开始安装依赖于C的gems,并能够使用以下命令安装sqlite3

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”时,我查找了如何安装,并尝试在MSYS 2中安装,它似乎做到了。

tyky79it

tyky79it1#

windows并不是rails的最佳选择,会有很多问题,一切都会变得更加复杂。强烈推荐使用Limitations in running Ruby/Rails on windows Linux,您可以使用双引导或WSL,也可以

相关问题