如何阻止RVM干扰JRuby

时间:2020-12-06 17:09:25

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:

我使用Warbler从我的Ruby源创建一个Jar文件。我也安装了RVM。 jar的行为根据Ruby版本RVM使用的不同而不同:如果我使用jruby然后jar正常工作,但如果我使用2.2,那么运行jar会将这些警告消息打印到控制台:

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:

如果我使用ruby-1.9.3-p484,那么运行jar实际上会失败:

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.

如果我在没有安装rvm的计算机上运行jar,它可以正常工作。

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

造成这种情况的原因是什么,以及如何阻止RVM干扰我的jar?

1 个解决方案

#1


2  

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.

它不仅仅是RVM的责任,系统Ruby安装也可能受到干扰......取消设置GEM_HOME和GEM_PATH环境变量,以便它们不被使用。

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)

如果它是.war你也可以尝试通过嵌入式JRuby完全隔离,使用jruby.runtime.env = false系统属性(或app context init参数)启动带有空ENV的Ruby运行时

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

对于打包的.jar存档,请使用config.override_gem_home(也应该与.war一起使用)

#1


2  

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.

它不仅仅是RVM的责任,系统Ruby安装也可能受到干扰......取消设置GEM_HOME和GEM_PATH环境变量,以便它们不被使用。

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)

如果它是.war你也可以尝试通过嵌入式JRuby完全隔离,使用jruby.runtime.env = false系统属性(或app context init参数)启动带有空ENV的Ruby运行时

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

对于打包的.jar存档,请使用config.override_gem_home(也应该与.war一起使用)