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
- Add JRuby::Util.internal_libraries for bootsnap. In https://github.com/Shopify/bootsnap/issues/162, I reported that bootsnap's load path caching breaks JRuby's internal extensions, since they do not ... — committed to jruby/jruby by headius 6 years ago
- Remove Bootsnap from the project Bootsnap has issues loading constants GitHub: https://github.com/Shopify/bootsnap/issues/162 — committed to jedrekdomanski/bikeramp by jedrekdomanski 6 years ago
- Move builtin libraries to direct loads or external files. This is for Shopify/bootsnap#162, and should allow all our "built in" libraries to have their require paths cached like any other library. T... — committed to jruby/jruby by headius 5 years ago
- Move builtin libraries to direct loads or external files. This is for Shopify/bootsnap#162, and should allow all our "built in" libraries to have their require paths cached like any other library. T... — committed to jruby/jruby by headius 5 years ago
- Move builtin libraries to direct loads or external files. This is for Shopify/bootsnap#162, and should allow all our "built in" libraries to have their require paths cached like any other library. T... — committed to jruby/jruby by headius 5 years ago
- Move builtin libraries to direct loads or external files. This is for Shopify/bootsnap#162, and should allow all our "built in" libraries to have their require paths cached like any other library. T... — committed to jruby/jruby by headius 5 years ago
- Move builtin libraries to direct loads or external files. This is for Shopify/bootsnap#162, and should allow all our "built in" libraries to have their require paths cached like any other library. T... — committed to jruby/jruby by headius 5 years ago
- Move builtin libraries to direct loads or external files. This is for Shopify/bootsnap#162, and should allow all our "built in" libraries to have their require paths cached like any other library. T... — committed to jruby/jruby by headius 5 years ago
- Remove Bootsnap from the project Bootsnap has issues loading constants GitHub: https://github.com/Shopify/bootsnap/issues/162 — committed to doremi9/bikeramp by doremi9 6 years ago
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.