From 449d3518f639c4670b82efa65e7f4fba01aefd13 Mon Sep 17 00:00:00 2001 From: Cody Cutrer Date: Sun, 28 Aug 2022 13:45:35 -0600 Subject: [PATCH] [jrubyscripting] avoid polluting environment when auto-installing gems (#13328) fixes https://github.com/boc-tothefuture/openhab-jruby/issues/634; regression from https://github.com/openhab/openhab-addons/pull/13151 Signed-Off-By: Cody Cutrer --- .../internal/JRubyScriptEngineConfiguration.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bundles/org.openhab.automation.jrubyscripting/src/main/java/org/openhab/automation/jrubyscripting/internal/JRubyScriptEngineConfiguration.java b/bundles/org.openhab.automation.jrubyscripting/src/main/java/org/openhab/automation/jrubyscripting/internal/JRubyScriptEngineConfiguration.java index 27f4e6322..dbf631fdd 100644 --- a/bundles/org.openhab.automation.jrubyscripting/src/main/java/org/openhab/automation/jrubyscripting/internal/JRubyScriptEngineConfiguration.java +++ b/bundles/org.openhab.automation.jrubyscripting/src/main/java/org/openhab/automation/jrubyscripting/internal/JRubyScriptEngineConfiguration.java @@ -164,8 +164,10 @@ public class JRubyScriptEngineConfiguration { } String[] gems = gemsConfigElement.getValue().get().split(","); - String gemCommand = "require 'bundler/inline'\nrequire 'openssl'\n\ngemfile(" + checkUpdate + ") do\n" - + " source 'https://rubygems.org/'\n"; + // Set update_native_env_enabled to false so that bundler doesn't leak + // into other script engines + String gemCommand = "require 'jruby'\nJRuby.runtime.instance_config.update_native_env_enabled = false\nrequire 'bundler/inline'\nrequire 'openssl'\n\ngemfile(" + + checkUpdate + ") do\n" + " source 'https://rubygems.org/'\n"; int validGems = 0; for (String gem : gems) { gem = gem.trim();