Nokogiri vs SU2018

I am struggling with ruby 2.8 which is incorporated in the latest release of SU2018.
I tried several xlsx readers
Neither of them works. (They can not be installed)
The common root problem is that all of them are using nokogiri gem.
Nokogiri is preinstalled gem by SU.
Unfortunately nokogiri works only with ruby version 2.7.
Anybody has a guess what can be done?

In SU2019 the Ruby API was upgraded to Ruby 2.5.1

# v2018
#v 2019

why do you think this?


Thank you. Yes you are right
The title of the topic is wrong. It should be nokogiri vs SU2018

Please see the error messages during installation roo
(very similar error messages can be seen for all the other xlsx reader installations)

Error: #<Gem::InstallError: nokogiri requires Ruby version <, >= 2.3.>
C:/Program Files/SketchUp/SketchUp 2018/Tools/RubyStdLib/rubygems/installer.rb:560:in ensure_required_ruby_version_met' C:/Program Files/SketchUp/SketchUp 2018/Tools/RubyStdLib/rubygems/installer.rb:782:inpre_install_checks’
C:/Program Files/SketchUp/SketchUp 2018/Tools/RubyStdLib/rubygems/installer.rb:231:in install' C:/Program Files/SketchUp/SketchUp 2018/Tools/RubyStdLib/rubygems/request_set.rb:166:inblock in install’
C:/Program Files/SketchUp/SketchUp 2018/Tools/RubyStdLib/rubygems/request_set.rb:150:in each' C:/Program Files/SketchUp/SketchUp 2018/Tools/RubyStdLib/rubygems/request_set.rb:150:ininstall’
C:/Program Files/SketchUp/SketchUp 2018/Tools/RubyStdLib/rubygems/dependency_installer.rb:394:in install' C:/Program Files/SketchUp/SketchUp 2018/Tools/RubyStdLib/rubygems.rb:558:ininstall’

:in `' SketchUp:1:in `eval'

SU v18 only ships with Ruby 2.2.4, which is less than 2.3…

when gem tries to load it as a dependancy for roo, it fails…

it is not preinstalled in SU…

on SU v19, which has a usable version of Ruby, you will get an error as nokogiri needs to be compiled…

Error: #<Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

I did use ‘xml-simple-1.1.5’ for something in v18, but I can’t even remember what…

there are many threads on the problems with gems in the embedded ruby interpreter…



Gem.install 'nokogiri','1.9.1'

An alternative may be the REXML library that is supplied in the standard library, and is coded in pure Ruby. No need to compile anything or use gems or have your customers install gems.

  • Note that when they show you can include the REXML module, that you ONLY do so into YOUR namespace or plugin modules, NOT into SketchUp’s main Ruby Objectspace.

Thank you for yor suggestion.
Please note

  1. I used roo for almost one year under SU2018 without any problem on my old PC.
  2. It seems that the a good solution could be if I upgrade to SU2019.
    This the hottest topic nowdays. I am as much confused about this as most of the average SU users.
    (I just renewed, 4 days before the announcment of the new licensing structure, my traditional supscription. )
    I have the very same problem as Michael
    Updating Licence for 2019

Thank you for suggestion.
At least rubyXL can installed after installing nokigiri in this way.

Thank you for your suggestion.
I browsed REXML library description. It seems clear to me.
However for my present problem it is not the solution.
I do not want to reinvent the wheel. i.e. to write a complete package for parsing xlsx files.

Anyway I duly noted your suggestion. Sometimes XML files are to be parsed.
Presently I have a LAZARUS program which makes the parsing of very special xml files and export them to xlsx format

1 Like

SU2021 pro vs nokogiri and rubyXL or roo

New SU major version was downloaded unfortunately the xlsx file parsing problem is back again.
(Please note that in SU2020 there was no problem at all)

In SU2021 the nokogiri gem is installed however neither rubyXL nor roo can be installed.

Pleae find below the install log for rubyXL (in case of roo the error log is very similar)

Gem.install ‘rubyXL’
Error: #<Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory: C:/Users/Munka/AppData/Roaming/SketchUp/SketchUp 2021/SketchUp/Gems64/gems/nokogiri-1.10.10/ext/nokogiri

C:/Program\ Files/SketchUp/SketchUp\ 2021/Tools/bin/ruby.exe -I C:/Program\ Files/SketchUp/SketchUp\ 2021/Tools/RubyStdLib -r ./siteconf20201204-2872-kb9ke3.rb extconf.rb
extconf failedNo such file or directory - C:/Program Files/SketchUp/SketchUp 2021/Tools/bin/ruby.exe

Gem files will remain installed in C:/Users/Munka/AppData/Roaming/SketchUp/SketchUp 2021/SketchUp/Gems64/gems/nokogiri-1.10.10 for inspection.
Results logged to C:/Users/Munka/AppData/Roaming/SketchUp/SketchUp 2021/SketchUp/Gems64/extensions/x64-mswin64-140/2.7.0/nokogiri-1.10.10/gem_make.out

C:/Program Files/SketchUp/SketchUp 2021/Tools/RubyStdLib/rubygems/ext/builder.rb:78:in rescue in run' C:/Program Files/SketchUp/SketchUp 2021/Tools/RubyStdLib/rubygems/ext/builder.rb:77:in run’
C:/Program Files/SketchUp/SketchUp 2021/Tools/RubyStdLib/rubygems/ext/ext_conf_builder.rb:48:in block in build' C:/Program Files/SketchUp/SketchUp 2021/Tools/RubyStdLib/tempfile.rb:291:in open’
C:/Program Files/SketchUp/SketchUp 2021/Tools/RubyStdLib/rubygems/ext/ext_conf_builder.rb:30:in build' C:/Program Files/SketchUp/SketchUp 2021/Tools/RubyStdLib/rubygems/ext/builder.rb:167:in block in build_extension’
C:/Program Files/SketchUp/SketchUp 2021/Tools/RubyStdLib/rubygems/ext/builder.rb:163:in synchronize' C:/Program Files/SketchUp/SketchUp 2021/Tools/RubyStdLib/rubygems/ext/builder.rb:163:in build_extension’
C:/Program Files/SketchUp/SketchUp 2021/Tools/RubyStdLib/rubygems/ext/builder.rb:208:in block in build_extensions' C:/Program Files/SketchUp/SketchUp 2021/Tools/RubyStdLib/rubygems/ext/builder.rb:205:in each’
C:/Program Files/SketchUp/SketchUp 2021/Tools/RubyStdLib/rubygems/ext/builder.rb:205:in build_extensions' C:/Program Files/SketchUp/SketchUp 2021/Tools/RubyStdLib/rubygems/installer.rb:844:in build_extensions’
C:/Program Files/SketchUp/SketchUp 2021/Tools/RubyStdLib/rubygems/installer.rb:327:in install' C:/Program Files/SketchUp/SketchUp 2021/Tools/RubyStdLib/rubygems/resolver/specification.rb:93:in install’
C:/Program Files/SketchUp/SketchUp 2021/Tools/RubyStdLib/rubygems/request_set.rb:195:in block in install' C:/Program Files/SketchUp/SketchUp 2021/Tools/RubyStdLib/rubygems/request_set.rb:183:in each’
C:/Program Files/SketchUp/SketchUp 2021/Tools/RubyStdLib/rubygems/request_set.rb:183:in install' C:/Program Files/SketchUp/SketchUp 2021/Tools/RubyStdLib/rubygems/dependency_installer.rb:325:in install’
C:/Program Files/SketchUp/SketchUp 2021/Tools/RubyStdLib/rubygems.rb:631:in `install’

:in `' ...

Please edit your posts and wrap error text correctly …

[How to] Post correctly formatted and colorized code on the forum?

Native gems cannot be built inside SketchUp. You must use pure-Ruby gems or pre-built gem binaries.

There are numerous topics about this in this category.

*Windows specific*

Except for possibly a very long time ago, SketchUp’s Ruby has always been a ‘mingw’ build. One can see this when typing RUBY_DESCRIPTION into the console. The description ends with [x64-mingw32]. These were compiled with either MSYS or MSYS2 gcc tools. ‘gcc’ tools are the standard tools used by many *nix OS’s.

With SU 2021, the description ends with [x64-mswin64_140]. Its Ruby is compiled with the Microsoft compile tools. This change was done due to compatibility issues, as Windows SU is also compiled with Microsoft tools.

Now, re Nokogiri and other gems (like sqlite3), the RubyGems web site shows several packages available for each version. Note that there is a version for ‘x64-mingw32’. This gem is pre-compiled for a range of Ruby versions, and works with Ruby mingw builds.

There is not an ‘mswin’ version.

Bottom line, unless one can compile the gems themselves, they cannot be used in SU 2021 and later versions…

Finally, Ruby itself is built and tested with both mingw and mswin builds. So, Ruby is supporting mswin, but very few gems do so.

SU 2021 has a dll that has an unexpected name. I’m not sure what that implies…

Anyway, you may be able to use the mingw Nokogiri version. It may not work, but it does load. Please test it, and be aware that SU may crash. I don’t have the time nor the code to test it.

Goto All versions of nokogiri |, and download the most recent ‘x64-mingw32’ version (currently 1.11.0.rc3), then run

Gem.install '<full path to file>'

It installs the gem. You are running a mingw compiled gem in an mswin Ruby, which is something I have never tried…

Thank you for your reply. However I am not closer to the solution.
I have no idea what a pure ruby gem is. (I googled it but no useful link was found) I suppose I have used native gems so far. For me a gem is a black box/ or collection of useful routines with well defined interface. Please give us a clear guidence how to convert a native gem to “pure” ruby gem.
Just for background information in my SU universe every component is parametric and all the instances of a component too. These parameters are stored in an .xlsx file. If an xlsx file is can not be parsed then SU2021 can be used only as a little bit enhanced SU Viewer.

Thank you for your advice. However it does not solve my problem.
I downloaded the latest nokogiri-1.11.0.rc3-x86-mingw32.gem. It could be installed without any error message. SU2021 did not collapse.
However it is not working.
If later on various versions of rubyXL or roo were installed all of them reinstalled nokogiri-1.10.10 but rubyXL or roo were not.


If you type the following in the SU Ruby console, what’s the output?

require 'nokogiri'; Nokogiri::VERSION

It consists of code all in plain text Ruby code.

You cannot. A native gem is written in C and compiled. Plain text Ruby code is interpreted.

The SketchUp API has attribute dictionaries so that parameters can be saved with the objects inside the model database.

But that aside, Nokogiri is not the only means of reading an XML file. Ruby comes with a standard library called REXML (that can read and write XML files) as well as a CSV class (that can read and write CSV files output from Excel.)

Thank you for your quick reply.
Now I understand everything but I am not happy at all.

I checked your recommendation REXML. Yes, it can read XML files,
Yes, an XLSX file is a bundle of XML files.
However REXML is very far from to fully parse an XLSX file.
Just one issue in my XLSX files formulas are heavily used to ensure that one SU component instance is just at the right location and orientation
or one component fits to another. If REXML is to be used then all the formula parsing should be written too.

Referring SU API attribute dictionaries. It is good to know. However for most of the cases they are not applicable for me. A lot of data are exported from other (lighting design) applications to an XLSX file. This xlsx file is processed in SU.