Skip to content

fix: further isolate jars/wars by ensuring gems are not loaded from user home/default locations - #648

Merged
chadlwilson merged 2 commits into
jruby:masterfrom
chadlwilson:further-isolate-gem-path
Aug 29, 2026
Merged

fix: further isolate jars/wars by ensuring gems are not loaded from user home/default locations#648
chadlwilson merged 2 commits into
jruby:masterfrom
chadlwilson:further-isolate-gem-path

Conversation

@chadlwilson

@chadlwilson chadlwilson commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

The current semantics allow RubyGems to re-calculate GEM_PATH to its default semantics which would include Gem.default_path
which otherwise allows gems to load from a host Gem.user_dir. This is totally undesirable for warbler's purposes, which are
to make jars/wars self contained - they should be able to load everything from inside the jar.

There is some risk that this breaks some edge cases not properly handled by warbler, where people
are installing on host to workaround issues with correct packaging of extensions, however we need
to fix these issues properly without corrupting isolation by default. I think the "escape hatch" of
disabling override_gem_home is probably enough to opt out of this, but will re-evaluate if issues
are reported.

Note that related issues have been addressed over time via the below issues, however now Rubygems (and bundler) is more intrsinsically baked into the JRubies we support and we only officially support using Warbler via JRuby itself (not CRuby); so the approach can be simplified somewhat.

…ser home/defualt locations

The current semantics allow RubyGems to re-calculate GEM_PATH to its default semantics which would include `Gem.default_path`
which otherwise allows gems to load from a host Gem.user_dir. This is totally undesirable for warbler's purposes, which are
to make jars/wars self contained - they should be able to load everything from inside the jar.

There is some risk that this breaks some edge cases not properly handled by warbler, where people
are installing on host to workaround issues with correct packaging of extensions, however we need
to fix these issues properly without corrupting isolation by default. I think the "escape hatch" of
disabling `override_gem_home` is probably enough to opt out of this, but will re-evaluate if issues
are reported.
@chadlwilson chadlwilson added this to the 2.1.2 milestone Aug 29, 2026
@chadlwilson
chadlwilson marked this pull request as ready for review August 29, 2026 07:31
@chadlwilson
chadlwilson merged commit 0a2bbae into jruby:master Aug 29, 2026
14 checks passed
@chadlwilson
chadlwilson deleted the further-isolate-gem-path branch August 29, 2026 07:32
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

Successfully merging this pull request may close these issues.

1 participant