[jruby] How to integrate local GEMs, when running from a ScriptingContainer?

changepoint_advi.fischer at extaccount.com changepoint_advi.fischer at extaccount.com
Tue Jan 12 19:00:00 JST 2016


> From: JRuby [mailto:jruby-bounces at ruby-lang.org] On Behalf Of christian

> jruby -S gem install GEMNAME --install-dir .
> jruby -r jruby/commands -e JRuby::Commands.generate_dir_info ./gems
> jruby -r jruby/commands -e JRuby::Commands.generate_dir_info ./specifications
>
> jar cvfm app.jar ..... gems specifications
> then use IsolatedScriptingContainer which will set GEM_HOME and GEM_PATH to uri:classloader:/ that is where the gems are found inside the jar. no need to set it manually.
> - christian

Hi Christian,

thanks for the explanation. In short - it basically works, after a few trivial modifications.

As you said, IsolatedScriptingContainer makes the use of GEM_HOME/GEM_PATH unnecessary.  One difference between my setup and yours (and which turned out was the cause of most headache) was, that you used the project directory for installing the gems (--install-dir .), while I was putting them into a subdirectory (--install-dir gem), because I didn't want the directories 'specifications', 'cache' etc. to show up into our top level project directory. However, this requires to use a trick, when putting the gem into a jar: I can't simply include 'gem', nor 'gem/gems', into the jar. Even with an IsolatedScriptingContainer, the gems would not be found. Instead, I have to use

    jar ..... -C gem gems -C gem specification

From my understanding, the -C gem flag "lifts" the gem directories one level up inside the jar file, and this seems to be necessary for the gems to be located.

I have also included the JRuby::Commands.generate_dir_info  commands, actually in a slightly different forms (you forgot the quote characters):

    jruby -r jruby/commands -e "JRuby::Commands.generate_dir_info 'gem/gems'"
    jruby -r jruby/commands -e "JRuby::Commands.generate_dir_info 'gem/specifications'"

I just wonder, why these are necessary. I googled for generate_dir_info, but didn't find anything which would explain, what this command does and why it is necessary here. Could you enlighten me in this respect?

Ronald

If you are not the addressee, please inform us immediately that you have received this e-mail by mistake, and delete it. We thank you for your support.



More information about the JRuby mailing list