https://projects.ecoinformatics.org/ecoinfo/https://projects.ecoinformatics.org/ecoinfo/ecoinfo/favicon.ico?14691340362009-06-12T20:16:23ZEcoinformatics RedmineKepler - Bug #4152: Modules should be able to add environment variables to the runtimehttps://projects.ecoinformatics.org/ecoinfo/issues/4152?journal_id=140812009-06-12T20:16:23ZDavid Welkerwelker4kepler@gmail.com
<ul></ul><p>Just so I understand this correctly, this is a distinct use case from setting System properties, correct? So, if you had the location stored in a system property, that would not be adequate?</p> Kepler - Bug #4152: Modules should be able to add environment variables to the runtimehttps://projects.ecoinformatics.org/ecoinfo/issues/4152?journal_id=140822009-06-12T20:48:40ZChad Berkleyberkley@nceas.ucsb.edu
<ul></ul><p>Right. It is distinct because it actually needs to load an environment variable.</p> Kepler - Bug #4152: Modules should be able to add environment variables to the runtimehttps://projects.ecoinformatics.org/ecoinfo/issues/4152?journal_id=140832009-06-12T20:50:49ZChristopher Brookscxh@eecs.berkeley.edu
<ul></ul><p>In Java 1.5 and later the java.lang.System.getEnv() method returns <br />environment variables. <br />The Javadoc for getEnv() says:</p>
<p>"System properties and environment variables are both conceptually mappings<br />between names and values. Both mechanisms can be used to pass user-defined<br />information to a Java process. Environment variables have a more global effect,<br />because they are visible to all descendants of the process which defines them,<br />not just the immediate Java subprocess. They can have subtly different<br />semantics, such as case insensitivity, on different operating systems. For<br />these reasons, environment variables are more likely to have unintended side<br />effects. It is best to use system properties where possible. Environment<br />variables should be used when a global effect is desired, or when an external<br />system interface requires an environment variable (such as PATH)."</p>
<p>So, I think that if R is being invoked as a separate process or is running<br />a C call to getenv(), then we would need to set the environment variables.</p>
<p>The Java Process class can pass environment variables to subprocesses.</p>
<p>I don't think there is a Java setEnv() command. One way to make this work<br />would be to define a Parameter that is a Record that could be referred to<br />by the External Execution actor (which uses ptolemy.actor.lib.Exec) in<br />the environment actor parameter. This would allow subprocesses to <br />access the updated environment variables. I don't know if a JNI call<br />to a C library that calls the C getenv() function would see any change<br />in the environment.</p> Kepler - Bug #4152: Modules should be able to add environment variables to the runtimehttps://projects.ecoinformatics.org/ecoinfo/issues/4152?journal_id=140842009-06-12T20:53:02ZChad Berkleyberkley@nceas.ucsb.edu
<ul></ul><p>You can, in fact, add env vars to the runtime. We do it for the PATH variable (for JNI on windows). I'm implementing this functionality now.</p> Kepler - Bug #4152: Modules should be able to add environment variables to the runtimehttps://projects.ecoinformatics.org/ecoinfo/issues/4152?journal_id=140852009-06-12T20:59:39ZChad Berkleyberkley@nceas.ucsb.edu
<ul></ul><p>Added the ability to the build system to parse a $module/module-info/environment.txt file. This file lists the environment variables that should be loaded by the java runtime at startup. Variables can be loaded either independently of the OS or they can depend on a specific OS.</p>
<p>The syntax is as follows:</p>
<p><env_name>:[<env_os>]=<value></p>
<p>An example:<br />R_HOME:Mac OS X=/Library/Frameworks/R.framework/Resources</p>
<p>or</p>
<p>MY_PATH=/x/y/z</p> Kepler - Bug #4152: Modules should be able to add environment variables to the runtimehttps://projects.ecoinformatics.org/ecoinfo/issues/4152?journal_id=140862013-03-27T21:25:50ZRedmine Admin
<ul></ul><p>Original Bugzilla ID was 4152</p>