How to unset or properly set GEM_HOME in a war with warbler/glassfish?

Hello,

We found this thread [1], but we have the opposite request. In our
WAR, GEM_HOME seems to always be set to the system gem home. We don’t
want this, because we don’t want any system gems to pollute our load
path when we deploy our war to customers.

We’ve tried:

  • setting ENV[‘GEM_HOME’] to nil in config/preinitializer.rb - but
    then the rails environment won’t even start
  • setting config.webxml.GEM_HOME=‘’ and config.webxml.gem.home=‘’ in
    warble.rb - this set the properties in web.xml, but they had no effect
    on GEM_HOME or Gem.dir.

Gem.path is correctly set to the to the path of WEB-INF/gems under
glassfish.

Questions:

  • How can we make use WEB-INF/gems under glassfish as our GEM_HOME?
  • What is setting Gem.path correctly to WEB-INF/gems under glassfish?
    Warbler? Glassfish? Something else?

Thanks,
– Chad

[1]
http://www.nabble.com/How-to-set-GEM_PATH-in-warbler--td21997785.html


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

On Fri, Oct 23, 2009 at 5:44 PM, Chad W. [email protected]
wrote:

  • setting config.webxml.GEM_HOME=‘’ and config.webxml.gem.home=‘’ in
    warble.rb - this set the properties in web.xml, but they had no effect
    on GEM_HOME or Gem.dir.

Gem.path is correctly set to the to the path of WEB-INF/gems under glassfish.

Questions:

  • How can we make use WEB-INF/gems under glassfish as our GEM_HOME?
  • What is setting Gem.path correctly to WEB-INF/gems under glassfish?
    Warbler? Glassfish? Something else?

I’ll address the second question first, since it will help answer the
first one. JRuby-Rack, the Java shim library included with Warbler,
responsible for booting Rails in the Java container, is the one
setting up GEM_PATH. It sets it fairly early in the startup process,
before the Rails initializer is loaded, so I’m pretty sure the
following in config/environment.rb or config/preinitializer.rb should
work:

ENV[“GEM_HOME”] = ENV[“GEM_PATH”]

/Nick


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

On Sat, Oct 24, 2009 at 11:11 PM, Nick S. [email protected]
wrote:

ENV[“GEM_HOME”] = ENV[“GEM_PATH”]

Thanks, that’s what we ended up doing, or more specifically (since
path is an array):

ENV[“GEM_HOME”] = ENV[“GEM_PATH”].first

It seems like this should be exposed as an option in warble.rb, or at
least some way to disable the loading of system GEM_HOME.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email