tag:help.appveyor.com,2012-11-13:/discussions/problems/19287-how-to-unset-environment-variables-in-ubuntu-imageAppVeyor: Discussion 2019-01-16T16:52:00Ztag:help.appveyor.com,2012-11-13:Comment/468073202019-01-15T21:47:13Z2019-01-15T21:47:13ZHow to unset environment variables in Ubuntu image?<div><p>I guess I should have opened this in "Questions". I am not sure how to move it.</p></div>dmoody256tag:help.appveyor.com,2012-11-13:Comment/468073202019-01-16T16:32:05Z2019-01-16T16:32:05ZHow to unset environment variables in Ubuntu image?<div><p>Actually, this is actually normal behavior: before executing any command (or block of commands) from the appveyor.yaml file we save environment variables into a file then we restore it back.<br>
However, you can write a block of bash code in yaml file:<br></p>
<pre>
<code> - sh: |
unset JAVA_TOOL_OPTIONS
<execute other stuff>
python$PYTHON runtest.py -l test/Repository/Java.py >> exclude_list.txt</code>
</pre>
This will unset variable till the end of <code>sh</code> block.
<p>Also, you may try to unset variable right while executing bash command:<br></p>
<pre>
<code> - sh: JAVA_TOOL_OPTIONS= python$PYTHON runtest.py -l test/Repository/Java.py >> exclude_list.txt</code>
</pre>
This will set JAVA_TOOL_OPTIONS to empty string and execute python tests.</div>Wasa Pleshakovtag:help.appveyor.com,2012-11-13:Comment/468073202019-01-16T16:46:57Z2019-01-16T16:46:57ZHow to unset environment variables in Ubuntu image?<div><p>Also there is <code>env</code> command which run a program in a modified environment :<br></p>
<pre>
<code>env -u JAVA_TOOL_OPTIONS python$PYTHON runtest.py -l test/Repository/Java.py >> exclude_list.txt</code>
</pre>
this will unset <code>JAVA_TOOL_OPTIONS</code> for python.</div>Wasa Pleshakovtag:help.appveyor.com,2012-11-13:Comment/468073202019-01-16T16:51:48Z2019-01-16T16:51:48ZHow to unset environment variables in Ubuntu image?<div><p>My python tests are creating subprocesses which execute with the default os environment. I would rather not change the tests to run with a prescribed environment just for appveyor, which would specialize the code to appveyor. So if I can do it from the appveyor.yml that would be best.</p>
<p>Setting that environment variable to empty string still cause issues for my Java tests. Java puts output to stderr when the JAVA_TOOL_OPTIONS is in the environment.</p>
<p>I tested with your solution and the sh block and this worked<br></p>
<pre>
<code> - sh: |
unset JAVA_TOOL_OPTIONS</code>
</pre>
<a href="https://ci.appveyor.com/project/dmoody256/scons/builds/21667678">https://ci.appveyor.com/project/dmoody256/scons/builds/21667678</a></div>dmoody256