Setting GEM_HOME/GEM_PATH on scripting-container


is there a way to set GEM_HOME/GEM_PATH for ScriptingContainer per
instance ?

currently I use the environment Map to set it and it works OK for the
first ScriptingContainer but any further instance of
ScriptingContainer just does not obey the new environment Map. so the
first scripting container require ‘rubygems’ wins.

  • Kristian

Does something like this work for you?

ScriptingContainer container = new ScriptingContainer();
container.runScriptlet(“ENV[‘GEM_PATH’]='” + basepath +

There is a good write up on Yoko’s blog:


On Thu, Sep 13, 2012 at 12:38 AM, Brendan Grainger
[email protected] wrote:

Does something like this work for you?

I tried this as well. it works OK for the first container. if make a
second one with different GEM_PATH that GEM_PATH gets omited by
rubygems, i.e.
p Gem.path
will give me the GEM_PATH I set on the first container. it feels like
rubygems gets shared between different instances of ScriptngContainer

also tried a few of scope and behaviour settings without luck.

thanx anyways.

  • Kristian