0

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 execpacman -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.

  • If you new to ruby and using Windows, I highly recommend to use WSL environment to develop ruby projects. It's much easier than using MSYS2 and MINGW. – ironsand May 12 '22 at 04:57

1 Answers1

0

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