rspreadsheet icon indicating copy to clipboard operation
rspreadsheet copied to clipboard

libxml gem not installed automatically on windows

Open gorn opened this issue 4 years ago • 9 comments

I have tried to use the gem under windows and althought libxml is not installed natively I get error

C:/Users/jatesins/AppData/Ruby25-x64/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require': cannot load such file -- libxml (LoadError)

even after

gem install libxml-ruby

I still get the same. This at least should be explained in DOCS.

gorn avatar Sep 18 '19 10:09 gorn

There is some info at https://github.com/xml4r/libxml-ruby

gem install x64-mingw32

but is does not work on my windows

gorn avatar Sep 18 '19 10:09 gorn

Another idea (but not a solution) https://github.com/xml4r/libxml-ruby/issues/125 suggests gem install libxml-ruby --platform=x64-mingw32, but infortunately it does not work either.

gorn avatar Sep 18 '19 12:09 gorn

This problem also exists on Debian, though apt install ruby-libxml fixes it here

singpolyma avatar Oct 17 '19 23:10 singpolyma

on debian, the gem is trying to check whether ruby-libxml is intalled natively and if not, than install it as gem. if that does not work, than it is another issue

gorn avatar Oct 18 '19 14:10 gorn

on debian, the gem is trying to check whether ruby-libxml is intalled natively and if not, than install it as gem. if that does not work, than it is another issue

Sorry for hijacking the issue - it also does not work on Linux Mint 18.2 (Ubuntu based). Both solutions from this comment solve the problem (downgrade to 0.4.4 or add libxml-ruby to own Gemfile). Tested on rspreadsheet 0.5.3.

kammerer avatar Nov 18 '19 13:11 kammerer

I've also had problems with the libxml gem when trying to use rspreadsheet on Windows (both 7 & 10) with Ruby 2.5.5, even after trying the suggestions above.

I noticed my C:\Ruby\Ruby255-x64\lib\ruby\gems\2.5.0\gems\libxml-ruby-3.0.0-x64-mingw32\lib folder has a 2.4 subfolder containing libxml_ruby.so, but no 2.5 subfolder. As the .so files on Windows are specific to a particular Ruby minor version, this suggests this gem will only work with Ruby 2.4.x.

(Interestingly, C:\Ruby\Ruby255-x64\lib\ruby\gems\2.5.0\gems\libxml-ruby-3.1.0-x64-mingw32\lib does not even have a 2.4 subfolder, so I don't know that libxml-ruby 3.1.0 will work on Windows at all).

The libxml-ruby page on github says "The gem includes prebuilt extensions for Ruby 2.3", suggesting that only specific minor Ruby versions are supported.

I installed Ruby 2.4.9, libxml-ruby 3.0.0, and rspreadsheet 0.5.3 on Windows 7.

libxml_ruby.so has been installed here: C:\Ruby\Ruby249-x64\lib\ruby\gems\2.4.0\gems\libxml-ruby-3.0.0-x64-mingw32\lib\2.4\libxml_ruby.so but ruby looks for it here: C:\Ruby\Ruby249-x64\lib\ruby\gems\2.4.0\gems\libxml-ruby-3.0.0-x64-mingw32\lib\libxml_ruby.so To fix this, manually copy libxml_ruby.so one level higher in the folder tree.

libxml2-2.dll has been installed here: C:\Ruby\Ruby249-x64\lib\ruby\gems\2.4.0\gems\libxml-ruby-3.0.0-x64-mingw32\lib\libs\libxml2-2.dll but ruby looks for it here: C:\Ruby\Ruby249-x64\bin\libxml2-2.dll Manually copy libxml2-2.dll to the path above.

Now ruby cannot find liblzma-5.dll.  There isn't a copy in any of my Ruby folders, so I searched my entire hard drive and found a copy here: C:\Program Files\Git\mingw64\bin\liblzma-5.dll and manually copied it here: C:\Ruby\Ruby249-x64\bin\liblzma-5.dll This file happens to be version 5.2.4.0, 154,319 bytes

After copying these 3 files, rspreadsheet works fine on Windows!

While tracking down these file problems, my test case was to require 'rspreadsheet' in irb. If a .so/.dll wasn't present in the correct subfolder, I'd get output like the following:

I hope this information is helpful to someone.

irb(main):001:0> require 'rspreadsheet'
LoadError: 126: The specified module could not be found.   - C:/Ruby/Ruby249-x64/lib/ruby/gems/2.4.0/gems/libxml-ruby-3.0.0-x64-mingw32/lib/libxml_ruby.so
        from C:/Ruby/Ruby249-x64/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from C:/Ruby/Ruby249-x64/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from C:/Ruby/Ruby249-x64/lib/ruby/gems/2.4.0/gems/libxml-ruby-3.0.0-x64-mingw32/lib/libxml.rb:8:in `rescue in <top (required)>'
        from C:/Ruby/Ruby249-x64/lib/ruby/gems/2.4.0/gems/libxml-ruby-3.0.0-x64-mingw32/lib/libxml.rb:4:in `<top (required)>'
        from C:/Ruby/Ruby249-x64/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from C:/Ruby/Ruby249-x64/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from C:/Ruby/Ruby249-x64/lib/ruby/gems/2.4.0/gems/rspreadsheet-0.5.3/lib/rspreadsheet/workbook.rb:2:in `<top (required)>'
        from C:/Ruby/Ruby249-x64/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from C:/Ruby/Ruby249-x64/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from C:/Ruby/Ruby249-x64/lib/ruby/gems/2.4.0/gems/rspreadsheet-0.5.3/lib/rspreadsheet.rb:2:in `<top (required)>'
        from C:/Ruby/Ruby249-x64/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from C:/Ruby/Ruby249-x64/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from (irb):1
        from C:/Ruby/Ruby249-x64/bin/irb.cmd:19:in `<main>'

rubycoder avatar Nov 22 '19 01:11 rubycoder

FYI just installed rspreadsheet on macos catalina and it didn't install libxml-ruby here either.

doriantaylor avatar Jun 16 '20 19:06 doriantaylor

Using Debian 10, rspreadsheet 0.5.3, and having ruby-libxml 3.1.0-1 installed, I had to run gem install libxml-ruby to be able to require rspreadsheet.

Kawsay avatar Jul 26 '21 08:07 Kawsay

I couldn't get rspreadsheet to work under Windows 10/Ruby 3.0.2p107:

C:/Ruby/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:332:in `require': cannot load such file -- libxml_ruby (LoadError)

libxml-ruby's suggestion to gem install libxml-ruby-x64-mingw32 doesn't work, I assume because it's built against Ruby 2.7 and I'm on Ruby 3.0 (have raised https://github.com/xml4r/libxml-ruby/issues/176):

C:\path>gem install libxml-ruby-x64-mingw32
ERROR:  Could not find a valid gem 'libxml-ruby-x64-mingw32' (>= 0) in any repository

soundasleep avatar Nov 22 '21 03:11 soundasleep