Repository navigation
Avoid use of bundler/setup during rails booting #459
Description
Currently jruby-rack tries to boot rails in the standish-way that can swallow any bundler errors if Java is not configured with particular --add-opens etc (depending on platform). it does this via:
jruby-rack/src/main/ruby/jruby/rack/rails/environment.rb
Lines 22 to 27 in c464485
| def load_environment | |
| require expand_path('config/boot.rb') | |
| require 'jruby/rack/rails/railtie' | |
| require expand_path('config/environment.rb') | |
| require 'jruby/rack/rails/extensions' | |
| end |
The issue is that an off-the-shelf Rails config/boot.rb will do require bundler/setup to Boot rails. This is problematic because in order to determine which mode to run in, Bundler does an stdout.tty? check.
Unfortunately this particular check is problematic on JRuby because it requires all manner of native access to do correctly, and versions prior to 10.0.7.0 will silently return true if these are not available, due to jruby/jruby#9590 This then causes bundler to do things like System.exit any time there is an error, which will be caught by the servlet container and otherwise swallow any actual Bundling error.
It also does problematic things like trying to auto_switch to locked bundler versions and auto_install gems, which should not be done within jruby-rack. The former has been a problem for some time, requiring workarounds such as locking to the same jruby-bundled bundler version, or using BUNDLE_VERSION=system and/or BUNDLE_DISABLE_SHARED_GEMS=1 when building ones application; neither of which should be required at build time.
All of this is probably unnecessary.
- jruby-rack can always assume there is no tty
- theoretically we can call
Bundler.setupprogrammatically prior to the user's boot and short-circuit all of this- this assumes bundler is in use. I believe this is fine, as think using Bundler is required for rails?
- unfortunately we would not know any custom
Bundler.setupthe user is doing in theirconfig.boot.rb.- we may need to parse/grep
config/boot.rband only do our ownBundler.setupif there is none there; or if we seerequire bundler/setup.
- we may need to parse/grep
- after that, the user's
require 'bundler/setup'should be largely a no-op; or at least the tty status will be irrelevant.
Activity