Skip to content

JRuby 9.4.13.0 introduces LoadError: no such file to load -- Win32API via stdlib/net/http on Windows #8866

@chadlwilson

Description

@chadlwilson

Environment Information

  • JRuby 9.4.13.0 loaded via jruby-complete on classpath.
  • Windows Server Core 2022
  • Rails 7.0.x with Zeitwerk

When executing tests and sprockets assets pipeline, we invoke JRuby via classpath and some custom start scripts generated by gradle which set up environment and then launch jruby directly via java with custom classpath and args.

It may be that we need to change something to adapt to a change in JRuby 9.4.13.0.

Expected Behavior

Should be able to load/run things that rely on resolv.rb from Rake/jruby-complete as before (?).

Actual Behavior

When trying to load net/http via Capybara on JRuby 9.4.13.0 we now get the below on Windows. Seems OK on Linux.

This was working fine on 9.4.12.1 and earlier 9.4.x versions.

> Task :server:compileAssetsRailsTest
Using environment variables
   CLASSPATH='C:\Users\ContainerAdministrator\.gradle\caches\modules-2\files-2.1\org.jruby\jruby-complete\9.4.13.0\cd5051d913f9e356979e48bc40169b7bdc16d9b2\jruby-complete-9.4.13.0.jar' \
    GEM_HOME='C:\go\pipelines\build-windows\server\src\main\webapp\WEB-INF\rails\gems\jruby\3.1.0' \
    GEM_PATH='C:\go\pipelines\build-windows\server\src\main\webapp\WEB-INF\rails\gems\jruby\3.1.0' \
        PATH='C:\go\pipelines\build-windows\server\scripts;C:\go\pipelines\build-windows\server\src\main\webapp\WEB-INF\rails\gems\jruby\3.1.0\bin;C:\Program Files\\Perforce\\bin;C:\tools\msys64\ucrt64\bin;C:\tools\msys64\usr\bin;C:\tools\ruby34\bin;C:\Program Files\Eclipse Adoptium\jdk-21.0.6.7-hotspot\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\ProgramData\chocolatey\bin;C:\Program Files\nodejs\;C:\Program Files\Git\cmd;C:\Program Files (x86)\nant-0.92\bin;C:\Program Files\Perforce\;C:\Users\ContainerAdministrator\AppData\Local\Microsoft\WindowsApps;C:\Users\ContainerAdministrator\AppData\Roaming\npm;C:\Program Files\Mercurial\;C:\tools\msys64' \
   RAILS_ENV='test' \
RAILS_GROUPS='assets' \
        RUBY='C:/go/pipelines/build-windows/server/scripts/jruby.bat' \
[C:\go\pipelines\build-windows\server\src\main\webapp\WEB-INF\rails]$ java -Dcruise.config.dir=C:\go\pipelines\build-windows\server\target\railsTests\config -Dgo.enforce.server.immutability=N -Djdk.net.URLClassPath.disableClassPathURLCheck=true -Djruby.home=uri:classloader://META-INF/jruby.home -Dplugins.external.provided.path=C:\go\pipelines\build-windows\server\target\railsTests\plugins\external -Dplugins.go.provided.path=C:\go\pipelines\build-windows\server\target\railsTests\plugins\bundled -Dplugins.work.path=C:\go\pipelines\build-windows\server\target\railsTests\plugins\work -Drails.use.compressed.js=false -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant org.jruby.Main -S rake --trace assets:clobber assets:precompile
rake aborted!
LoadError: no such file to load -- Win32API
Did you mean?  win32api
org/jruby/RubyKernel.java:1187:in `require'
uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:144:in `require'
uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/win32/registry.rb:3:in `<main>'
org/jruby/RubyKernel.java:1187:in `require'
uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:144:in `require'
uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/win32/resolv.rb:7:in `<main>'
org/jruby/RubyKernel.java:1187:in `require'
uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:144:in `require'
uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/resolv.rb:1001:in `default_config_hash'
uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/resolv.rb:84:in `initialize'
org/jruby/RubyClass.java:916:in `new'
uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/resolv.rb:3430:in `<class:Resolv>'
uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/resolv.rb:34:in `<main>'
org/jruby/RubyKernel.java:1187:in `require'
uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:144:in `require'
uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/net/http.rb:25:in `<main>'
org/jruby/RubyKernel.java:1187:in `require'
uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:144:in `require'
C:/go/pipelines/build-windows/server/src/main/webapp/WEB-INF/rails/gems/jruby/3.1.0/gems/capybara-3.40.0/lib/capybara/server.rb:4:in `<main>'
org/jruby/RubyKernel.java:1187:in `require'
uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:144:in `require'
C:/go/pipelines/build-windows/server/src/main/webapp/WEB-INF/rails/gems/jruby/3.1.0/gems/capybara-3.40.0/lib/capybara.rb:454:in `<module:Capybara>'
C:/go/pipelines/build-windows/server/src/main/webapp/WEB-INF/rails/gems/jruby/3.1.0/gems/capybara-3.40.0/lib/capybara.rb:10:in `<main>'
org/jruby/RubyKernel.java:1187:in `require'
uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/bundler/runtime.rb:65:in `block in require'
org/jruby/RubyArray.java:2009:in `each'
uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/bundler/runtime.rb:60:in `block in require'
org/jruby/RubyArray.java:2009:in `each'
uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/bundler/runtime.rb:52:in `require'
uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/bundler.rb:215:in `require'
C:/go/pipelines/build-windows/server/src/main/webapp/WEB-INF/rails/config/application.rb:12:in `<main>'
org/jruby/RubyKernel.java:1187:in `require'
org/jruby/RubyKernel.java:1216:in `require_relative'
C:/go/pipelines/build-windows/server/src/main/webapp/WEB-INF/rails/Rakefile:13:in `<main>'
org/jruby/RubyKernel.java:1223:in `load'
C:/go/pipelines/build-windows/server/src/main/webapp/WEB-INF/rails/gems/jruby/3.1.0/gems/rake-13.3.0/lib/rake/rake_module.rb:29:in `load_rakefile'
C:/go/pipelines/build-windows/server/src/main/webapp/WEB-INF/rails/gems/jruby/3.1.0/gems/rake-13.3.0/lib/rake/application.rb:741:in `raw_load_rakefile'
C:/go/pipelines/build-windows/server/src/main/webapp/WEB-INF/rails/gems/jruby/3.1.0/gems/rake-13.3.0/lib/rake/application.rb:126:in `block in load_rakefile'
C:/go/pipelines/build-windows/server/src/main/webapp/WEB-INF/rails/gems/jruby/3.1.0/gems/rake-13.3.0/lib/rake/application.rb:214:in `standard_exception_handling'
C:/go/pipelines/build-windows/server/src/main/webapp/WEB-INF/rails/gems/jruby/3.1.0/gems/rake-13.3.0/lib/rake/application.rb:125:in `load_rakefile'
C:/go/pipelines/build-windows/server/src/main/webapp/WEB-INF/rails/gems/jruby/3.1.0/gems/rake-13.3.0/lib/rake/application.rb:82:in `block in run'
C:/go/pipelines/build-windows/server/src/main/webapp/WEB-INF/rails/gems/jruby/3.1.0/gems/rake-13.3.0/lib/rake/application.rb:214:in `standard_exception_handling'
C:/go/pipelines/build-windows/server/src/main/webapp/WEB-INF/rails/gems/jruby/3.1.0/gems/rake-13.3.0/lib/rake/application.rb:80:in `run'
C:/go/pipelines/build-windows/server/src/main/webapp/WEB-INF/rails/gems/jruby/3.1.0/gems/rake-13.3.0/exe/rake:27:in `<main>'
org/jruby/RubyKernel.java:1223:in `load'
uri:classloader:/META-INF/jruby.home/bin/rake:25:in `<main>'

Additional information

May relate to #8506 (?) and/or #7307 , #7547

Initiating line is

require 'Win32API'

via

require 'win32/resolv'

and

@resolvers = resolvers || [Hosts.new, DNS.new(DNS::Config.default_config_hash.merge(use_ipv6: use_ipv6))]

Interstingly, master/10.0.0.1 doesn't have this require in registry.rb due to

ed2679c#diff-214de3cfd07c836f1acab856b5613dad84497ba4324e1356edda1c46ef67c626L2-R3

Seems some potentially related discussion/comment about classloading working differently at #7547 (comment) that makes me possibly think require 'Win32API' won't work with win32api.rb (lowercase), and perhaps was not being used/invoked on earlier versions?

I suspect perhaps you can make require 'Win32API' or require 'win32api' work via case-sensitive classloading, but perhaps not both...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions