Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stop RVM interfering with JRuby

I have used Warbler to create a Jar file from my Ruby source. I also have RVM installed. The behaviour of the jar differs depending on which Ruby version RVM is using: if I rvm use jruby then the jar works normally, but if I rvm use 2.2 then running the jar prints these warning messages to the console:

Ignoring executable-hooks-1.3.2 because its extensions are not built.  Try: gem pristine executable-hooks --version 1.3.2
Ignoring gem-wrappers-1.2.7 because its extensions are not built.  Try: gem pristine gem-wrappers --version 1.2.7

And if I rvm use ruby-1.9.3-p484 then running the jar actually fails:

Ignoring unf_ext-0.0.7.1 because its extensions are not built.  Try: gem pristine unf_ext --version 0.0.7.1
Ignoring nokogiri-1.6.2.1 because its extensions are not built.  Try: gem pristine nokogiri --version 1.6.2.1
Ignoring nokogiri-1.6.6.2 because its extensions are not built.  Try: gem pristine nokogiri --version 1.6.6.2
Ignoring nokogiri-1.6.6.2 because its extensions are not built.  Try: gem pristine nokogiri --version 1.6.6.2
Ignoring executable-hooks-1.3.2 because its extensions are not built.  Try: gem pristine executable-hooks --version 1.3.2
Ignoring gem-wrappers-1.2.7 because its extensions are not built.  Try: gem pristine gem-wrappers --version 1.2.7
Ignoring nokogiri-1.6.2.1 because its extensions are not built.  Try: gem pristine nokogiri --version 1.6.2.1
Ignoring unf_ext-0.0.7.1 because its extensions are not built.  Try: gem pristine unf_ext --version 0.0.7.1
NameError: uninitialized constant Nokogiri::XERCES_VERSION
 const_missing at org/jruby/RubyModule.java:2733
       to_hash at /vagrant/myproject!/gems/nokogiri-1.6.6.2-java/lib/nokogiri/version.rb:73
       ...

If I run the jar on computer without rvm installed, it works fine.

What is causing this, and how do I stop RVM from interfering with my jar?

like image 809
fblundun Avatar asked Jul 28 '15 09:07

fblundun


1 Answers

its not simply RVM to blame, the system Ruby installation might have interfered as well ... unset GEM_HOME and GEM_PATH environment variables so that they're not used.

if it's a .war you can also try isolating completely by the embed JRuby to start a Ruby runtime with an empty ENV using jruby.runtime.env=false system property (or app context init parameter)

for packaged .jar archives use config.override_gem_home (should work with .war as well)

like image 78
kares Avatar answered Nov 17 '22 10:11

kares