Menu

#10 MSYS2 ruby package problem

1.0
closed
Alexx83
None
2014-10-12
2014-01-09
No

The current ruby package has problem loading native libraries (at least kernel32.dll). Let me explain.

I installed the package from MSYS2 to check how it was playing with mintty since ruby from RubyInstaller is not playing well with it. First, I updated rubygems to its latest version using gem update --system which worked great.

I then tried to install the bundler gem via gem install bundler and received this error message:

ERROR:  While executing gem ... (Fiddle::DLError)
    can't load kernel32.dll

Search a bit on the internet, nothing seemed to be available about this error. I navigate in the rubygems library and the problem comes from a call to dns.getresource("_rubygems._tcp.#{host}", Resolv::DNS::Resource::IN::SRV) which probably make a native call to kernel32.dll hence loading the kernel32.dll library.

I made a small test case to easily reproduce the problem:

require fiddle

kernel = Fiddle::Handle.new("kernel32.dll")
puts "Function address: #{kernel['GetEnvironmentStrings']}"

This will not work in ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-msys]. However, I tested with ruby 2.0.0p353 (2013-11-22) [x64-mingw32] which is shipped by the Windows RubyInstaller project and the test case works with their ruby version.

However, if I specify the full path to the library, it will work correctly.

kernel = Fiddle::Handle.new("c:/Windows/System32/kernel32.dll")

Since this work, I wonder if it's not a path problem. With the msys2 package, the ENV['PATH'] is in Unix format where as in the mingw32 package, the ENV['PATH'] is in Windows format. Maybe a bad assumption in the msys2 package prevents locating the library correctly...

At this point, I'm not too sure in which direction to look. I guess trying to compile that package on my development machine would be a good starting point.

If I can help, don't hesitate to give some potential directions to take.

Regards,
Matt

P.S. I attached my full ruby test case to this issue.

1 Attachments

Discussion

  • Alexx83

    Alexx83 - 2014-01-09
    • assigned_to: Alexx83
     
  • Alexx83

    Alexx83 - 2014-01-09
    • status: open --> accepted
     
  • Alexx83

    Alexx83 - 2014-01-09

    I try to investigate problem.
    Using unix path you can also load library:
    kernel = Fiddle::Handle.new("/c/Windows/System32/kernel32.dll")

     
  • Matthieu Vachon

    Matthieu Vachon - 2014-01-09

    kernel = Fiddle::Handle.new("/c/Windows/System32/kernel32.dll")

    I guess this would not work on the mingw32 package right? Since the path transformation is probably handled by MSYS2 directly.

     
  • Alexx83

    Alexx83 - 2014-01-09

    I need to understand what do you need. MSYS version of Ruby or MINGW version of Ruby?
    MINGW Ruby package is mingw-w64-i686-ruby or mingw-w64-x86_64-ruby

     
  • Matthieu Vachon

    Matthieu Vachon - 2014-01-09

    Ok, I didn't know there was mingw-w64-i686-ruby and mingw-w64-x86_64-ruby packages available to install via pacman. I think I must clarify a bit. Just to say that I have always used MSys in the past, and now, I'm just starting testing MSys2.

    Right now, my ruby installations comes from Windows RubyInstaller project. When installed, their ruby version reports as [(i386)|x64) minwg32]. With those, the native library is loaded correctly. However, they do not play well with mintty console, which is not recognized as a tty, like many other software.

    While searching for a ruby package with pacman, I found the msys version of it (can't remember the exact name). I installed it and the native library does not load correctly with it. So, there is something not working with this package.

    Now, you point me that there is mingw-w64 packages of ruby. I'm at work right now and I can't test those packages. I will try when I get home tonight where my "testing" setup of MSys2 is.

    I hope it clarifies things for you. If something is still unclear, just tell me.

    Matt

     
  • Matthieu Vachon

    Matthieu Vachon - 2014-01-10

    Hi Alex,

    I tested package mingw-w64-x86_64-ruby and it works as expected, i.e. it is loading the native library correctly.

    So only the msys version as the problem.

    Regards,
    Matt

     
  • Matthieu Vachon

    Matthieu Vachon - 2014-07-13

    I just installed version 2.1.2-3 and the problem is not present anymore. The test case pass and it's possible to load a native library without a full absolute path.

    This issue can be closed.

     
  • Alexx83

    Alexx83 - 2014-07-14
    • status: accepted --> closed