bootsnap: Bootsnap breaks loading all internal JRuby extensions

We discovered today (release day for 9.1.17.0…grumble) that bootsnap is broken on JRuby, which breaks any rails apps using it. The problem appears to be that bootsnap refuses to load any files which it cannot find physically on the filesystem. JRuby ships a number of libraries within its .jar archive, so they would not be visible to bootsnap. In addition, many of our core extensions are “virtual” in that we register a loadable entry for them but they do not exist as a .jar (or .so or .dll) anywhere in the system.

The error manifests like this:

$ jruby   -S rails server
NameError: uninitialized constant CGI::Util::Escape
                       const_missing at org/jruby/RubyModule.java:3370
                       <module:Util> at /Users/headius/projects/jruby/lib/ruby/stdlib/cgi/util.rb:10
                         <class:CGI> at /Users/headius/projects/jruby/lib/ruby/stdlib/cgi/util.rb:9
                              <main> at /Users/headius/projects/jruby/lib/ruby/stdlib/cgi/util.rb:8
                             require at org/jruby/RubyKernel.java:956
                     block in (root) at /Users/headius/projects/jruby/lib/ruby/gems/shared/gems/bootsnap-1.3.0-java/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:1
           require_with_bootsnap_lfi at /Users/headius/projects/jruby/lib/ruby/gems/shared/gems/bootsnap-1.3.0-java/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21
                            register at /Users/headius/projects/jruby/lib/ruby/gems/shared/gems/bootsnap-1.3.0-java/lib/bootsnap/load_path_cache/loaded_features_index.rb:65
           require_with_bootsnap_lfi at /Users/headius/projects/jruby/lib/ruby/gems/shared/gems/bootsnap-1.3.0-java/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20
                              <main> at /Users/headius/projects/jruby/lib/ruby/gems/shared/gems/bootsnap-1.3.0-java/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29
                             require at org/jruby/RubyKernel.java:956

The actual problem, hidden by cgi.rb’s load of cgi/escape, is a cryptic error from bootsnap:

#<Class:0x4066c471>: cannot load such file -- cgi/escape
                             require at /Users/headius/projects/jruby/lib/ruby/gems/shared/gems/bootsnap-1.3.0-java/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32
                              <main> at /Users/headius/projects/jruby/lib/ruby/stdlib/cgi/util.rb:5
                             require at org/jruby/RubyKernel.java:956
                     block in (root) at /Users/headius/projects/jruby/lib/ruby/gems/shared/gems/bootsnap-1.3.0-java/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:1
           require_with_bootsnap_lfi at /Users/headius/projects/jruby/lib/ruby/gems/shared/gems/bootsnap-1.3.0-java/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21
                            register at /Users/headius/projects/jruby/lib/ruby/gems/shared/gems/bootsnap-1.3.0-java/lib/bootsnap/load_path_cache/loaded_features_index.rb:65
           require_with_bootsnap_lfi at /Users/headius/projects/jruby/lib/ruby/gems/shared/gems/bootsnap-1.3.0-java/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20
                              <main> at /Users/headius/projects/jruby/lib/ruby/gems/shared/gems/bootsnap-1.3.0-java/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29
                             require at org/jruby/RubyKernel.java:956

Bootsnap should not assume all files that will be loaded exist on the filesystem, because there are at least two implementations for which that might not be the case.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 1
  • Comments: 17 (4 by maintainers)

Commits related to this issue

Most upvoted comments

Latest JRuby 9.2 (Ruby 2.5.0) also failed for Rails 5.2 application.

Ok, sorry, I’m just trying to get caught up on a bunch of issues I’ve ignored for a very long time without reloading all the context up-front.

We’re not doing anything JRuby-specific AFAIK. If there’s anything small we can do to avoid/prevent stepping on JRuby’s toes, please let me know.

I hope this get fixed soon. I tried to start a new rails project with the latest RVM supported JRuby (9.1.13.0) and it failed here too.