Skip to content
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

Gems not being required properly no such file to load -- bundler/shared_helpers #430

Closed
seandunn opened this issue Jun 12, 2018 · 12 comments

Comments

@seandunn
Copy link

Hi All,

jruby-rack (1.1.21); warbler (2.0.5); jruby 9.2.0.0

I'm trying to run a Warbler generated WAR file in a docker Tomcat container. The WAR actually works fine in an older container running on a server but fails with the error shown below on anything more recent.

My suspicion is that this is a $LOAD_PATH issue.
I've got gems being bundled into WEB-INF/gems and everything should be there.

If anyone who could throw some light onto this it would very much appreciated, thanks

org.jruby.rack.RackInitializationException: no such file to load -- bundler/shared_helpers
	from org/jruby/RubyKernel.java:970:in `require'
	from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:59:in `require'
	from file:/usr/local/tomcat/webapps/test_war/META-INF/init.rb:26:in `<eval>'
	from org/jruby/RubyKernel.java:1037:in `eval'
	from uri:classloader:/jruby/rack/booter.rb:256:in `block in load_settings_from_init_rb'
	from org/jruby/RubyArray.java:1801:in `each'
	from uri:classloader:/jruby/rack/booter.rb:243:in `load_settings_from_init_rb'
	from uri:classloader:/jruby/rack/booter.rb:99:in `boot!'
	from uri:classloader:/jruby/rack/rails_booter.rb:26:in `boot!'
	from uri:classloader:/jruby/rack/boot/rails.rb:10:in `<main>'
	from org/jruby/RubyKernel.java:994:in `load'
	from <script>:1:in `<main>'

	at org.jruby.rack.RackInitializationException.wrap(RackInitializationException.java:29)
	at org.jruby.rack.RackApplicationFactoryDecorator.init(RackApplicationFactoryDecorator.java:104)
	at org.jruby.rack.RackServletContextListener.contextInitialized(RackServletContextListener.java:50)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4792)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5256)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:754)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:730)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
	at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:985)
	at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1857)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: org.jruby.exceptions.LoadError: (LoadError) no such file to load -- bundler/shared_helpers
	at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:970)
	at RUBY.require(uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:59)
	at RUBY.<eval>(file:/usr/local/tomcat/webapps/test_war/META-INF/init.rb:26)
	at org.jruby.RubyKernel.eval(org/jruby/RubyKernel.java:1037)
	at RUBY.block in load_settings_from_init_rb(uri:classloader:/jruby/rack/booter.rb:256)
	at org.jruby.RubyArray.each(org/jruby/RubyArray.java:1801)
	at RUBY.load_settings_from_init_rb(uri:classloader:/jruby/rack/booter.rb:243)
	at RUBY.boot!(uri:classloader:/jruby/rack/booter.rb:99)
	at RUBY.boot!(uri:classloader:/jruby/rack/rails_booter.rb:26)
	at RUBY.<main>(uri:classloader:/jruby/rack/boot/rails.rb:10)
	at org.jruby.RubyKernel.load(org/jruby/RubyKernel.java:994)
	at RUBY.<main>(<script>:1)
@jlahtinen
Copy link

In META-INF/init.rb GEM_HOME and GEM_PATH environment variables are set correctly, but this information is not given to rubygems.

One possible fix is to add line Gem.paths = ENV before requiring bundler/shared_helpers in the same file.

@seandunn
Copy link
Author

Thanks so much @jlahtinen I'll give it a go and report back.

@seandunn
Copy link
Author

Sadly that didn't fix it.

I note that because the $servlet_context is defined, GEM_PATH is set to nil.
I've tried commenting that out as well but I'm still getting the no such file to load issue.

As far as I can see the paths are all correct for GEM_PATH, GEM_HOME and BUNDLE_GEMFILE.

@seandunn
Copy link
Author

So I noticed that jruby-jars version was did not match the jruby being used by warbler and bumped that by adding an explicit gem 'jruby-jars', '9.2.0.0' to my gemfile. When combined with Gem.paths = ENV fix suggested by @jlahtinen I get a new error and this time rendered in html (showing that JRuby::Rack::ErrorApp::ShowStatus is being loaded).

 No such file to load -- java.lang.IllegalArgumentException: Property 'messageSenders' is required.rb
	from org/jruby/RubyKernel.java:970:in `require'
	from /usr/local/tomcat/webapps/test_app/WEB-INF/gems/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `block in require'
	from /usr/local/tomcat/webapps/test_app/WEB-INF/gems/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:258:in `load_dependency'
	from /usr/local/tomcat/webapps/test_app/WEB-INF/gems/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require'
	from /usr/local/tomcat/webapps/test_app/WEB-INF/gems/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:379:in `block in require_or_load'
	from /usr/local/tomcat/webapps/test_app/WEB-INF/gems/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:36:in `block in load_interlock'
	from /usr/local/tomcat/webapps/test_app/WEB-INF/gems/gems/activesupport-5.1.6/lib/active_support/dependencies/interlock.rb:12:in `block in loading'
	from /usr/local/tomcat/webapps/test_app/WEB-INF/gems/gems/activesupport-5.1.6/lib/active_support/concurrency/share_lock.rb:149:in `exclusive'
	from /usr/local/tomcat/webapps/test_app/WEB-INF/gems/gems/activesupport-5.1.6/lib/active_support/dependencies/interlock.rb:11:in `loading'
	from /usr/local/tomcat/webapps/test_app/WEB-INF/gems/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:36:in `load_interlock'
	from /usr/local/tomcat/webapps/test_app/WEB-INF/gems/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:357:in `require_or_load'
	from /usr/local/tomcat/webapps/test_app/WEB-INF/gems/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:335:in `depend_on'
	from /usr/local/tomcat/webapps/test_app/WEB-INF/gems/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:251:in `require_dependency'
	from /usr/local/tomcat/webapps/test_app/WEB-INF/gems/gems/railties-5.1.6/lib/rails/engine.rb:476:in `block in eager_load!'
	from org/jruby/RubyArray.java:1801:in `each'
	from /usr/local/tomcat/webapps/test_app/WEB-INF/gems/gems/railties-5.1.6/lib/rails/engine.rb:475:in `block in eager_load!'
	from org/jruby/RubyArray.java:1801:in `each'
	from /usr/local/tomcat/webapps/test_app/WEB-INF/gems/gems/railties-5.1.6/lib/rails/engine.rb:473:in `eager_load!'
	from /usr/local/tomcat/webapps/test_app/WEB-INF/gems/gems/railties-5.1.6/lib/rails/engine.rb:354:in `eager_load!'
	from org/jruby/RubyArray.java:1801:in `each'
	from /usr/local/tomcat/webapps/test_app/WEB-INF/gems/gems/railties-5.1.6/lib/rails/application/finisher.rb:67:in `block in Finisher'
	from org/jruby/RubyBasicObject.java:2677:in `instance_exec'
	from /usr/local/tomcat/webapps/test_app/WEB-INF/gems/gems/railties-5.1.6/lib/rails/initializable.rb:30:in `run'
	from /usr/local/tomcat/webapps/test_app/WEB-INF/gems/gems/railties-5.1.6/lib/rails/initializable.rb:59:in `block in run_initializers'
	from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/tsort.rb:228:in `block in tsort_each'
	from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/tsort.rb:350:in `block in each_strongly_connected_component'
	from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/tsort.rb:431:in `each_strongly_connected_component_from'
	from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/tsort.rb:349:in `block in each_strongly_connected_component'
	from org/jruby/RubyArray.java:1801:in `each'
	from org/jruby/RubyMethod.java:129:in `call'
	from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/tsort.rb:347:in `each_strongly_connected_component'
	from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/tsort.rb:226:in `tsort_each'
	from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/tsort.rb:205:in `tsort_each'
	from /usr/local/tomcat/webapps/test_app/WEB-INF/gems/gems/railties-5.1.6/lib/rails/initializable.rb:58:in `run_initializers'
	from /usr/local/tomcat/webapps/test_app/WEB-INF/gems/gems/railties-5.1.6/lib/rails/application.rb:353:in `initialize!'
	from /usr/local/tomcat/webapps/test_app/WEB-INF/config/environment.rb:7:in `<main>'
	from org/jruby/RubyKernel.java:970:in `require'
	from uri:classloader:/jruby/rack/rails/environment3.rb:1:in `(root)'
	from uri:classloader:/jruby/rack/rails/environment3.rb:25:in `load_environment'
	from uri:classloader:/jruby/rack/rails_booter.rb:83:in `<main>'

@seandunn
Copy link
Author

OK I think I've solved this issue for me. In case anyone else references this, I had to turn of eager class loading in the rails production environment file.

I'm currently not sure how that's effecting things but it worked for jruby 9.1 WAR file builds. I also had to explicitly require the matching jruby-jars file in Gemfile.

Later builds using jruby 9.2 failed with no such file to load errors which I was able to resolve by adding Gems.paths = ENV to the META-INF/init.rb file before bundler require statement. As suggested by @jlahtinen.

@ketan
Copy link
Member

ketan commented Jul 11, 2018

This "workaround" seems like a kludge to me. I do believe this is a bug — esp because I'm facing this same issue, and my app used to work fine with jruby (v1.7.26) and jruby-rack (v1.1.21). Upgrading to jruby 9.2.0.0 seems to have caused the app to not boot up. Like you mentioned the issue is that despite setting GEM_HOME in init.rb — jruby seems to be unable to load bundler/setup.

@rsov
Copy link
Contributor

rsov commented Jul 11, 2018

I have the same issue: #432

@mengu
Copy link

mengu commented Jul 11, 2018

i have just updated our rails app to jruby 9.2 and have the same problem.

@arloan
Copy link

arloan commented Jul 14, 2018

Same problem here.

C:\temp>java -jar winstone-0.9.10.jar -war mas.war
[Winstone 2018/07/14 21:30:55] - Beginning extraction from war file
[Winstone 2018/07/14 21:31:00] - No webapp classes folder found - C:\Users\stone\AppData\Local\Temp\winstone\stone\mas.w
ar\WEB-INF\classes
[webapp 2018/07/14 21:31:00] - INFO: jruby 9.2.0.0 (2.5.0) 2018-05-24 81156a8 Java HotSpot(TM) Client VM 25.172-b11 on 1
.8.0_172-b11 +jit [mswin32-x86]
[webapp 2018/07/14 21:31:00] - INFO: using a shared (threadsafe!) runtime
uri:classloader:/jruby/rack/response.rb:294: warning: constant ::Fixnum is deprecated
uri:classloader:/jruby/rack/core_ext.rb:26: warning: constant ::NativeException is deprecated
[webapp 2018/07/14 21:31:06] - An exception happened during JRuby-Rack startup
no such file to load -- bundler/shared_helpers
--- System
jruby 9.2.0.0 (2.5.0) 2018-05-24 81156a8 Java HotSpot(TM) Client VM 25.172-b11 on 1.8.0_172-b11 +jit [mswin32-x86]
Time: 2018-07-14 21:31:06 +0800
Server: Winstone Servlet Engine v0.9.10
jruby.home: uri:classloader://META-INF/jruby.home

--- Context Init Parameters:
public.root = /
rack.env = production

--- Backtrace
LoadError: no such file to load -- bundler/shared_helpers
                              require at org/jruby/RubyKernel.java:970
                              require at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_r
equire.rb:59
                               <eval> at file:/C:/Users/stone/AppData/Local/Temp/winstone/stone/mas.war/META-INF/init.rb
:28
                                 eval at org/jruby/RubyKernel.java:1037
  block in load_settings_from_init_rb at uri:classloader:/jruby/rack/booter.rb:256
                                 each at org/jruby/RubyArray.java:1801
           load_settings_from_init_rb at uri:classloader:/jruby/rack/booter.rb:243
                                boot! at uri:classloader:/jruby/rack/booter.rb:99
                               <main> at uri:classloader:/jruby/rack/boot/rack.rb:10
                                 load at org/jruby/RubyKernel.java:994
                               <main> at <script>:1

--- RubyGems
Gem.dir: uri:classloader:/META-INF/jruby.home/lib/ruby/gems/shared
Gem.path:
C:/Users/stone/.gem/jruby/2.5.0
uri:classloader:/META-INF/jruby.home/lib/ruby/gems/shared
Activated gems:

--- Bundler
undefined method `bundle_path' for Bundler:Module

--- JRuby-Rack Config
compat_version =
default_logger = org.jruby.rack.logging.StandardOutLogger@19c42bd
equals = <error: >
err = java.io.PrintStream@13eb0d4
filter_adds_html = true
filter_verifies_resource = false
ignore_environment = false
initial_memory_buffer_size =
initial_runtimes =
jms_connection_factory =
jms_jndi_properties =
logger = org.jruby.rack.logging.ServletContextLogger@3cba3a
logger_class_name = servlet_context
logger_name = jruby.rack
maximum_memory_buffer_size =
maximum_runtimes =
num_initializer_threads =
out = java.io.PrintStream@a4dce5
rackup =
rackup_path =
rewindable = true
runtime_arguments =
runtime_environment =
runtime_timeout_seconds =
serial_initialization = false
servlet_context = winstone.WebAppConfiguration@817f46
throw_init_exception = false

--- $LOAD_PATH:
C:\Users\stone\AppData\Local\Temp\winstone\stone\mas.war\WEB-INF/
uri:classloader:/META-INF/jruby.home/lib/ruby/2.5/site_ruby
uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib

[webapp 2018/07/14 21:31:06] - ERROR: initialization failed
org.jruby.rack.RackInitializationException: no such file to load -- bundler/shared_helpers
        from org/jruby/RubyKernel.java:970:in `require'
        from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:59:in `require'
        from file:/C:/Users/stone/AppData/Local/Temp/winstone/stone/mas.war/META-INF/init.rb:28:in `<eval>'
        from org/jruby/RubyKernel.java:1037:in `eval'
        from uri:classloader:/jruby/rack/booter.rb:256:in `block in load_settings_from_init_rb'
        from org/jruby/RubyArray.java:1801:in `each'
        from uri:classloader:/jruby/rack/booter.rb:243:in `load_settings_from_init_rb'
        from uri:classloader:/jruby/rack/booter.rb:99:in `boot!'
        from uri:classloader:/jruby/rack/boot/rack.rb:10:in `<main>'
        from org/jruby/RubyKernel.java:994:in `load'
        from <script>:1:in `<main>'

        at org.jruby.rack.RackInitializationException.wrap(RackInitializationException.java:29)
        at org.jruby.rack.RackApplicationFactoryDecorator.init(RackApplicationFactoryDecorator.java:104)
        at org.jruby.rack.RackServletContextListener.contextInitialized(RackServletContextListener.java:50)
        at winstone.WebAppConfiguration.<init>(WebAppConfiguration.java:889)
        at winstone.HostConfiguration.initWebApp(HostConfiguration.java:131)
        at winstone.HostConfiguration.<init>(HostConfiguration.java:73)
        at winstone.HostGroup.initHost(HostGroup.java:85)
        at winstone.HostGroup.<init>(HostGroup.java:45)
        at winstone.Launcher.<init>(Launcher.java:196)
        at winstone.Launcher.main(Launcher.java:391)
Caused by: org.jruby.exceptions.LoadError: (LoadError) no such file to load -- bundler/shared_helpers
        at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:970)
        at RUBY.require(uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:59)
        at RUBY.<eval>(file:/C:/Users/stone/AppData/Local/Temp/winstone/stone/mas.war/META-INF/init.rb:28)
        at org.jruby.RubyKernel.eval(org/jruby/RubyKernel.java:1037)
        at RUBY.block in load_settings_from_init_rb(uri:classloader:/jruby/rack/booter.rb:256)
        at org.jruby.RubyArray.each(org/jruby/RubyArray.java:1801)
        at RUBY.load_settings_from_init_rb(uri:classloader:/jruby/rack/booter.rb:243)
        at RUBY.boot!(uri:classloader:/jruby/rack/booter.rb:99)
        at RUBY.<main>(uri:classloader:/jruby/rack/boot/rack.rb:10)
        at org.jruby.RubyKernel.load(org/jruby/RubyKernel.java:994)
        at RUBY.<main>(<script>:1)

[Winstone 2018/07/14 21:31:06] - HTTP Listener started: port=8080
[Winstone 2018/07/14 21:31:06] - AJP13 Listener started: port=8009
[Winstone 2018/07/14 21:31:06] - Winstone Servlet Engine v0.9.10 running: controlPort=disabled

@arloan
Copy link

arloan commented Jul 15, 2018

Confirmed that everything works fine with jruby-jars version 9.1.17.0 pre-installed on jruby 9.1.17.0 and warbler 2.0.5, jruby-jars 9.2.0.0 on jruby 9.1.17.0 not tested.

@ketan
Copy link
Member

ketan commented Aug 10, 2018

@arloan — I don't believe this is an issue specific to warbler. I'm seeing this particular issue without warbler. So I suspect it has to be something with jruby core, and not here.

@arloan
Copy link

arloan commented Aug 10, 2018

@ketan Yes, I realized that and deleted my previous post before u replied. ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants