conda / conda

A system-level, binary package and environment manager running on all major operating systems and platforms.
https://docs.conda.io/projects/conda/
Other
6.39k stars 1.66k forks source link

“unbound variable” ERROR when conda invoked within bash scripts containing command “set -u” #9966

Open jmborr opened 4 years ago

jmborr commented 4 years ago

Current Behavior

Script _/etc/conda/deactivate.d/glibdeactivate.sh restores the value of variable GSETTINGS_SCHEMA_DIR with the backup variable GSETTINGS_SCHEMA_DIR_CONDA_BACKUP, like this:

export GSETTINGS_SCHEMA_DIR=$GSETTINGS_SCHEMA_DIR_CONDA_BACKUP

This backup variable is set in script _/etc/conda/activate.d/glibactivate.sh, like this:

export GSETTINGS_SCHEMA_DIR_CONDA_BACKUP=${GSETTINGS_SCHEMA_DIR:-}

The problem: if GSETTINGS_SCHEMA_DIR is unbound, then GSETTINGS_SCHEMA_DIR_CONDA_BACKUP is unbound too.

The error: A bash script containing set -u will raise an unbound variable error if _glibdeactivate.sh runs as part of a conda command.

The solution: Statement in _glibdeactivate.sh should be:

export GSETTINGS_SCHEMA_DIR=${GSETTINGS_SCHEMA_DIR_CONDA_BACKUP:-}

mimicking the analogous statement in _glibactivate.sh.

Steps to Reproduce

Expected Behavior

Environment Information

`conda info`

``` ```

`conda config --show-sources`

``` ```

`conda list --show-channel-urls`

``` ```

yarikoptic commented 2 years ago

Thank you for this bug report since I just ran into it and now why it happened! Would be nice to see this elderly issue addressed!

nestordemeure commented 1 year ago

I am updating this issue to note that I found another unbound variable (CONDA_BACKUP_CXX).

Similarly to the current issue (and this past issue), it is triggered by a set -u followed by a call to conda activate inside a bash script.

Here is the relevant part of the error message:

/conda/deactivate.d/deactivate-gxx_linux-64.sh: line 68: CONDA_BACKUP_CXX: unbound variable
Nitin123-4 commented 1 year ago

Any thing can be done for this?

Nitin123-4 commented 8 months ago

Try adding this in the bash script:

set +eu SOURCE CONDA set -eu conda deactivate