-
-
Notifications
You must be signed in to change notification settings - Fork 925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial $LOAD_PATH depends on JRUBY_HOME in jruby-complete-9.0.0.0 #3257
Comments
So are you proposing that the jruby-complete.jar should ignore JRUBY_HOME? And it sounds like that was the case in 1.7.19 and earlier? |
I have to add that jruby whether it runs from filesystem install or from
jruby-complete.jar or from modular maven artifacts, it depends on the
GEM_HOME, GEM_PATH, JARS_HOME, BUNDLER_GEMFILE, etc. there is no real
isolation from the environment, unless you take care of those -
IsolatedScriptingContainer does eliminate a few of those. for example if
people use RVM then java -jar jruby-complete.jar will see the gems for
current ruby from RVM and this is even true when this is MRI ruby.
it is not so to determine the fact that you are running from
jruby-complete.jar or any other classpath with jruby-core.jar +
jruby-stdlib.jar from filesystem installation which is basically
jruby-core.jar + JRUBY_HOME set to some filesystem location.
|
Yes, exactly. I use JRUBY-COMPLETE as the base for a standalone application jar, which should run on any computer with the right operating system. Users should not have to worry about the environment it runs in. In a sense the ‘complete’ part of the name says it all. In cases where JRUBY_HOME is needed, it is probably better to use JRUBY. But maybe others have different use cases in favor of the use of JRUBY_HOME in JRUBY-COMPLETE |
I have one idea how to do this...if we set a different main for the complete jar versus the jruby.jar we put into a distribution, we'd know how it was launched. They'd essentially do the same thing, but when running from jar main it wouldn't look at environment variables...only properties. The other option would be to never look at environment vars in the Java code, and rely on the launchers to do it. Most people who use the env vars use our bin/jruby.bash or the native equivalent, which could just take those environment variables and put them in the right properties. |
let's say when there is a jruby-home on the classpath, i.e. there is
META-INF/jruby.home then we ignore JRUBY_HOME and use the one from the
classpath. that brings us back to jruby-1.7.x behaviour - I guess.
but we still obey jruby.home system property !
if this is way to go, I can spent implementing it.
there are other places where we try to detect whether we are running from
"jar" to make respawning of ruby possible for ruby libraries like rake.
the problem is not only jruby-complete but also jruby-jars.gem which has
two jars and one of it the jar from the distro. i.e. it should setup the
classpath with two jars: jruby-core-complete and jruby-stdlib
and if I just collect all my jars from org.jruby:jruby artifact than it
should behave the same as jruby-complete as these are exactly the same
classes. same the jars from jruby-jars.gem. all three should behave exactly
the same IMO.
|
I do not really understand the issue with jruby-jars.gem (probably because I never used it), but I would favor a solution where the default for jruby-complete is to ignore JRUBY_HOME. The solution as proposed by headius - to set a different main for the complete jar - seems a good way to achieve this. |
I am on it now. but the different main is tricky since the we have several distributions:
the last three use the same jars from a java point of view. they are only differently packed. one jar or two jars or many jars. and there is already a way to determine whether we run from classpath which contains so what I am about to do is give preference to the other issue is not clear to me: the best would be to look at or if you code runs from within a jar you can look at probably a check on a given file would help as well. let's see. |
@headius that the ScriptingContainer behaves differently, i.e. gives first preference to JRUBY_HOME is something which we do in jruby-1.7.x but I would go for a more uniform solution and remove those code lines: https://github.com/jruby/jruby/blob/master/core/src/main/java/org/jruby/embed/ScriptingContainer.java#L268 |
The default $LOAD_PATH for jruby-complete-9.0.0.0 depends on the environment variable JRUBY_HOME
In my opinion that is not desirable if you are running an application in a JAR, when you
need the initial $LOAD_PATH for access to the standard libraries and do not want
(accidental) interference with the libraries from outside the JAR.
If an application wants to take note of JRUBY_HOME it should do so by inspecting the
environment variable itself.
jruby-complete-1.7.19 did NOT depend on JRUBY_HOME, see following example:
C:\Projects\XLibriz\lib\java>CD C:\Projects\XLibriz\lib\java
The text was updated successfully, but these errors were encountered: