]> git.basschouten.com Git - openhab-addons.git/commitdiff
[jrubyscripting] avoid polluting environment when auto-installing gems (#13328)
authorCody Cutrer <cody@cutrer.us>
Sun, 28 Aug 2022 19:45:35 +0000 (13:45 -0600)
committerGitHub <noreply@github.com>
Sun, 28 Aug 2022 19:45:35 +0000 (21:45 +0200)
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 <cody@cutrer.us>
bundles/org.openhab.automation.jrubyscripting/src/main/java/org/openhab/automation/jrubyscripting/internal/JRubyScriptEngineConfiguration.java

index 27f4e632224bc3c57305019f5c15295e087b92eb..dbf631fdd54b8bf6628bac6e42498465163584a8 100644 (file)
@@ -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();