How to unset environment variables in Ubuntu image?

dmoody256's Avatar


15 Jan, 2019 09:45 PM

I am trying to unset this environment variable:

I tried various way but it is always there when i printenv:

I need the variable to not exist in the environment.

  1. 1 Posted by dmoody256 on 15 Jan, 2019 09:47 PM

    dmoody256's Avatar

    I guess I should have opened this in "Questions". I am not sure how to move it.

  2. Support Staff 2 Posted by Wasa Pleshakov on 16 Jan, 2019 04:32 PM

    Wasa Pleshakov's Avatar

    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.
    However, you can write a block of bash code in yaml file:

      - sh: |
          unset JAVA_TOOL_OPTIONS
          <execute other stuff>
          python$PYTHON -l test/Repository/ >> exclude_list.txt
    This will unset variable till the end of sh block.

    Also, you may try to unset variable right while executing bash command:

      - sh: JAVA_TOOL_OPTIONS= python$PYTHON -l test/Repository/ >> exclude_list.txt
    This will set JAVA_TOOL_OPTIONS to empty string and execute python tests.
  3. Support Staff 3 Posted by Wasa Pleshakov on 16 Jan, 2019 04:46 PM

    Wasa Pleshakov's Avatar

    Also there is env command which run a program in a modified environment :

    env -u JAVA_TOOL_OPTIONS python$PYTHON -l test/Repository/ >> exclude_list.txt
    this will unset JAVA_TOOL_OPTIONS for python.
  4. 4 Posted by dmoody256 on 16 Jan, 2019 04:51 PM

    dmoody256's Avatar

    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.

    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.

    I tested with your solution and the sh block and this worked

     - sh: |
          unset JAVA_TOOL_OPTIONS
  5. dmoody256 closed this discussion on 16 Jan, 2019 04:51 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

21 Aug, 2019 11:06 PM
21 Aug, 2019 02:08 PM
21 Aug, 2019 01:37 PM
21 Aug, 2019 10:21 AM
21 Aug, 2019 09:10 AM


21 Aug, 2019 05:56 AM
21 Aug, 2019 03:08 AM
20 Aug, 2019 11:33 PM
20 Aug, 2019 08:07 PM
20 Aug, 2019 05:50 PM
20 Aug, 2019 12:35 PM