New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bootsnap problems - fails to boot Rails under JRuby #5311

Open
kares opened this Issue Sep 14, 2018 · 5 comments

Comments

Projects
None yet
4 participants
@kares
Member

kares commented Sep 14, 2018

Environment

JRuby 9.1.16 as well as 9.2 (master tested as well)

Rubygems.org Rails app - using Rails 5.1.6

App

https://github.com/kares/rubygems.org/tree/jruby

git clone https://github.com/kares/rubygems.org.git
git co jruby
bundle install
rails s (or anything else e.g. rake test)

Expected Behavior

fails to boot under JRuby, unless bootsnap gets disabled (export NO_BOOTSNAP=true)

seemingly $LOAD_PATH does not end up being the same under JRuby compared to MRI

NameError: uninitialized constant CGI::Util::Escape
                       const_missing at org/jruby/RubyModule.java:3526
                       <module:Util> at /opt/local/rvm/rubies/jruby-9.2.0.0/lib/ruby/stdlib/cgi/util.rb:10
                         <class:CGI> at /opt/local/rvm/rubies/jruby-9.2.0.0/lib/ruby/stdlib/cgi/util.rb:9
                              <main> at /opt/local/rvm/rubies/jruby-9.2.0.0/lib/ruby/stdlib/cgi/util.rb:8
                             require at org/jruby/RubyKernel.java:970
                     block in (root) at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/bootsnap-1.3.2-java/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:1
           require_with_bootsnap_lfi at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/bootsnap-1.3.2-java/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21
                            register at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/bootsnap-1.3.2-java/lib/bootsnap/load_path_cache/loaded_features_index.rb:65
           require_with_bootsnap_lfi at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/bootsnap-1.3.2-java/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20
                              <main> at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/bootsnap-1.3.2-java/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29
                             require at org/jruby/RubyKernel.java:970
                     block in (root) at /opt/local/rvm/rubies/jruby-9.2.0.0/lib/ruby/stdlib/cgi/cookie.rb:2
                              (root) at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/bootsnap-1.3.2-java/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:1
           require_with_bootsnap_lfi at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/bootsnap-1.3.2-java/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21
                            register at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/bootsnap-1.3.2-java/lib/bootsnap/load_path_cache/loaded_features_index.rb:65
                              <main> at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/bootsnap-1.3.2-java/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20
                             require at org/jruby/RubyKernel.java:970
                    block in require at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/bootsnap-1.3.2-java/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29
                              (root) at /opt/local/rvm/rubies/jruby-9.2.0.0/lib/ruby/stdlib/cgi.rb:294
                              (root) at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/bootsnap-1.3.2-java/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:1
           require_with_bootsnap_lfi at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/bootsnap-1.3.2-java/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21
                              <main> at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/bootsnap-1.3.2-java/lib/bootsnap/load_path_cache/loaded_features_index.rb:65
                             require at org/jruby/RubyKernel.java:970
  block in require_with_bootsnap_lfi at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/bootsnap-1.3.2-java/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20
                             require at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/bootsnap-1.3.2-java/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29
                              (root) at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/i18n-1.1.0/lib/i18n/exceptions.rb:3
                              (root) at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/bootsnap-1.3.2-java/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:1
                              <main> at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/bootsnap-1.3.2-java/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21
                             require at org/jruby/RubyKernel.java:970
                   block in register at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/bootsnap-1.3.2-java/lib/bootsnap/load_path_cache/loaded_features_index.rb:65
           require_with_bootsnap_lfi at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/bootsnap-1.3.2-java/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20
                             require at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/bootsnap-1.3.2-java/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29
                              (root) at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/i18n-1.1.0/lib/i18n.rb:6
                              <main> at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/bootsnap-1.3.2-java/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:1
                             require at org/jruby/RubyKernel.java:970
  block in require_with_bootsnap_lfi at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/bootsnap-1.3.2-java/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21
                            register at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/bootsnap-1.3.2-java/lib/bootsnap/load_path_cache/loaded_features_index.rb:65
           require_with_bootsnap_lfi at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/bootsnap-1.3.2-java/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20
                             require at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/bootsnap-1.3.2-java/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29
                              <main> at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/activesupport-5.1.6/lib/active_support/i18n.rb:5
                             require at org/jruby/RubyKernel.java:970
                     block in (root) at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/bootsnap-1.3.2-java/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:1
           require_with_bootsnap_lfi at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/bootsnap-1.3.2-java/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21
                            register at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/bootsnap-1.3.2-java/lib/bootsnap/load_path_cache/loaded_features_index.rb:65
           require_with_bootsnap_lfi at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/bootsnap-1.3.2-java/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20
                              <main> at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/bootsnap-1.3.2-java/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29
                             require at org/jruby/RubyKernel.java:970
                     block in (root) at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/activesupport-5.1.6/lib/active_support/inflector/inflections.rb:4
                              (root) at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/bootsnap-1.3.2-java/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:1
           require_with_bootsnap_lfi at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/bootsnap-1.3.2-java/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21
                            register at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/bootsnap-1.3.2-java/lib/bootsnap/load_path_cache/loaded_features_index.rb:65
                              <main> at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/bootsnap-1.3.2-java/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20
                             require at org/jruby/RubyKernel.java:970
                    block in require at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/bootsnap-1.3.2-java/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29
                              (root) at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/activesupport-5.1.6/lib/active_support/inflector.rb:2
                              (root) at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/bootsnap-1.3.2-java/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:1
           require_with_bootsnap_lfi at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/bootsnap-1.3.2-java/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21
                              <main> at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/bootsnap-1.3.2-java/lib/bootsnap/load_path_cache/loaded_features_index.rb:65
                             require at org/jruby/RubyKernel.java:970
  block in require_with_bootsnap_lfi at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/bootsnap-1.3.2-java/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20
                             require at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/bootsnap-1.3.2-java/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29
                              (root) at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/activesupport-5.1.6/lib/active_support/core_ext/module/introspection.rb:1
                              (root) at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/bootsnap-1.3.2-java/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:1
           require_with_bootsnap_lfi at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/bootsnap-1.3.2-java/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21
                            register at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/bootsnap-1.3.2-java/lib/bootsnap/load_path_cache/loaded_features_index.rb:65
                              <main> at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/bootsnap-1.3.2-java/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20
                             require at org/jruby/RubyKernel.java:970
                              <main> at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/bootsnap-1.3.2-java/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29
                             require at org/jruby/RubyKernel.java:970
                              (root) at /opt/local/rvm/gems/jruby-9.2.0.0@rubygems/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:7
                              <main> at bin/rails:3
@headius

This comment has been minimized.

Show comment
Hide comment
@headius

headius Sep 18, 2018

Member

This was filed as a Bootsnap issue in Shopify/bootsnap#162.

The problem, I believe, is that Bootsnap is failing to load libraries that do not resolve to a file on the filesystem. In this case, it's due to cgi/escape being specially handled as an internal extension within JRuby (org.jruby.ext.cgi.escape.CGIEscape).

This should also affect non-internal extensions such as those using the "Service" load resource pattern common to third-party extensions like Nokogiri and concurrent-ruby. These extensions should continue to load via an uncached slow path, rather than failing altogether.

Member

headius commented Sep 18, 2018

This was filed as a Bootsnap issue in Shopify/bootsnap#162.

The problem, I believe, is that Bootsnap is failing to load libraries that do not resolve to a file on the filesystem. In this case, it's due to cgi/escape being specially handled as an internal extension within JRuby (org.jruby.ext.cgi.escape.CGIEscape).

This should also affect non-internal extensions such as those using the "Service" load resource pattern common to third-party extensions like Nokogiri and concurrent-ruby. These extensions should continue to load via an uncached slow path, rather than failing altogether.

@headius headius added this to the JRuby 9.2.1.0 milestone Sep 18, 2018

@enebo

This comment has been minimized.

Show comment
Hide comment
@enebo

enebo Sep 18, 2018

Member

Yeah this seems like an eventual endless paper chase for extensions. When the new hotness slim2electricboogaloo arrives on the rails scene then it cannot boot rails anymore?

Member

enebo commented Sep 18, 2018

Yeah this seems like an eventual endless paper chase for extensions. When the new hotness slim2electricboogaloo arrives on the rails scene then it cannot boot rails anymore?

@kares

This comment has been minimized.

Show comment
Hide comment
@kares

kares Sep 19, 2018

Member

oh nice, haven't looked around and did not realize this one isnt's in the FS as cgi/escape.rb
reading through the comments I'm amazed how tied Bootsnap ends up to MRI internals ;(

also duplicate of rails/rails#33462

Member

kares commented Sep 19, 2018

oh nice, haven't looked around and did not realize this one isnt's in the FS as cgi/escape.rb
reading through the comments I'm amazed how tied Bootsnap ends up to MRI internals ;(

also duplicate of rails/rails#33462

@ChrisBr

This comment has been minimized.

Show comment
Hide comment
@ChrisBr

ChrisBr Sep 19, 2018

Contributor

@kares are you planning to work on this soon? Otherwise I can maybe have a look at it tonight / Friday. I guess we 'just' need to make

877bcf4

available in bootsnap for now?

cc @headius

Contributor

ChrisBr commented Sep 19, 2018

@kares are you planning to work on this soon? Otherwise I can maybe have a look at it tonight / Friday. I guess we 'just' need to make

877bcf4

available in bootsnap for now?

cc @headius

@kares

This comment has been minimized.

Show comment
Hide comment
@kares

kares Sep 19, 2018

Member

@ChrisBr would be great if you can look into it ...

defined? JRuby::Util.internal_libraries would be a solution yes - although you will need to do some charade around resolving cgi/escape as "cgi/escape.jar". don't like that we need to resort to such internals, eventually for any Ruby implementation, they clearly break the existing Ruby load-path resolution rules. but if they accept the PR than I guess 🥇

Member

kares commented Sep 19, 2018

@ChrisBr would be great if you can look into it ...

defined? JRuby::Util.internal_libraries would be a solution yes - although you will need to do some charade around resolving cgi/escape as "cgi/escape.jar". don't like that we need to resort to such internals, eventually for any Ruby implementation, they clearly break the existing Ruby load-path resolution rules. but if they accept the PR than I guess 🥇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment