Skip to content
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

Unsetting of environmental variables is not fully working. #10171

Open
BastianZim opened this issue Aug 18, 2020 · 10 comments
Open

Unsetting of environmental variables is not fully working. #10171

BastianZim opened this issue Aug 18, 2020 · 10 comments
Labels
backlog issue has been triaged but has not been earmarked for any upcoming release severity::2 critical; broken functionality with an unacceptably complex workaround source::community catch-all for issues filed by community members stale::recovered [bot] recovered after being marked as stale type::bug describes erroneous operation, use severity::* to classify the type

Comments

@BastianZim
Copy link
Contributor

BastianZim commented Aug 18, 2020

Current Behavior

Hi, I set an environment variable via conda env config vars set my_var=value and then unset it via conda env config vars unset my_var -n test-env.

The variable is now not listed anymore under conda env config vars list but when I run conda update --all one of the outputs is (eval):unset:2: old-variable-name: invalid parameter name.

Steps to Reproduce

Included above.

Expected Behavior

Running conda env config vars unset my_var -n test-env should fully delete the variable.

Note: I also receive the following error, but I cannot fix that, no matter what I have tried, maybe it's connected:

Verifying transaction: / WARNING conda.core.path_actions:verify(963): Unable to create environments file. Path not writable.
  environment location: /Users/username/.conda/environments.txt

done
Executing transaction: \ WARNING conda.core.envs_manager:register_env(52): Unable to register environment. Path not writable or missing.
  environment location: /usr/local/anaconda3/envs/env_name
  registry file: /Users/username/.conda/environments.txt
done

Environment Information

`conda info`

     active environment : env_name
    active env location : /usr/local/anaconda3/envs/env_name
            shell level : 2
       user config file : /Users/username/.condarc
 populated config files : /Users/username/.condarc
          conda version : 4.8.4
    conda-build version : 3.18.11
         python version : 3.7.7.final.0
       virtual packages : __osx=10.15.6
       base environment : /usr/local/anaconda3  (writable)
           channel URLs : https://repo.anaconda.com/pkgs/main/osx-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/osx-64
                          https://repo.anaconda.com/pkgs/r/noarch
          package cache : /usr/local/anaconda3/pkgs
                          /Users/username/.conda/pkgs
       envs directories : /usr/local/anaconda3/envs
                          /Users/username/.conda/envs
               platform : osx-64
             user-agent : conda/4.8.4 requests/2.24.0 CPython/3.7.7 Darwin/19.6.0 OSX/10.15.6
                UID:GID : 501:20
             netrc file : None
           offline mode : False

`conda config --show-sources`

==> /Users/username/.condarc <==
ssl_verify: True
channels:
  - defaults
report_errors: True

`conda list --show-channel-urls`

# packages in environment at /usr/local/anaconda3/envs/env_name:
#
# Name                    Version                   Build  Channel
alabaster                 0.7.12                     py_0    defaults
applaunchservices         0.2.1                      py_0    defaults
appnope                   0.1.0                 py38_1001    defaults
argh                      0.26.2                   py38_0    defaults
astroid                   2.4.2                    py38_0    defaults
atomicwrites              1.4.0                      py_0    defaults
attrs                     19.3.0                     py_0    defaults
autopep8                  1.5.4                      py_0    defaults
babel                     2.8.0                      py_0    defaults
backcall                  0.2.0                      py_0    defaults
bleach                    3.1.5                      py_0    defaults
boto3                     1.14.43                    py_0    defaults
botocore                  1.17.43                    py_0    defaults
brotlipy                  0.7.0           py38haf1e3a3_1000    defaults
ca-certificates           2020.6.24                     0    defaults
cairo                     1.16.0            hec6a9b0_1003    conda-forge
cairocffi                 1.1.0                      py_0    conda-forge
cairosvg                  2.4.2                      py_0    conda-forge
certifi                   2020.6.20                py38_0    defaults
cffi                      1.14.0           py38hb5b8e2f_0    defaults
chardet                   3.0.4                 py38_1003    defaults
cloudpickle               1.5.0                      py_0    defaults
cryptography              2.9.2            py38ha12b0ac_0    defaults
cssselect2                0.3.0                    pypi_0    pypi
dbus                      1.13.16              h18a8e69_0    defaults
decorator                 4.4.2                      py_0    defaults
defusedxml                0.6.0                      py_0    defaults
diff-match-patch          20200713                   py_0    defaults
docutils                  0.15.2                   py38_0    defaults
entrypoints               0.3                      py38_0    defaults
expat                     2.2.9                hb1e8313_2    defaults
flake8                    3.8.3                      py_0    defaults
fontconfig                2.13.1            h6b1039f_1001    conda-forge
freetype                  2.10.2               ha233b18_0    defaults
fribidi                   1.0.9                haf1e3a3_0    defaults
future                    0.18.2                   py38_1    defaults
gettext                   0.19.8.1             h15daf44_3    defaults
glib                      2.65.0               h577aef8_0    conda-forge
graphite2                 1.3.14               h38d11af_0    defaults
harfbuzz                  2.4.0                hd8d2a14_3    conda-forge
html5lib                  1.1                        py_0    defaults
icu                       64.2                 h6de7cb9_1    conda-forge
idna                      2.10                       py_0    defaults
imagesize                 1.2.0                      py_0    defaults
importlib-metadata        1.7.0                    py38_0    defaults
importlib_metadata        1.7.0                         0    defaults
iniconfig                 1.0.1                      py_0    defaults
intervaltree              3.0.2                      py_1    defaults
ipykernel                 5.3.4            py38h5ca1d4c_0    defaults
ipython                   7.17.0           py38h39e3cac_0    defaults
ipython_genutils          0.2.0                    py38_0    defaults
isort                     4.3.21                   py38_0    defaults
jedi                      0.15.2                   py38_0    defaults
jinja2                    2.11.2                     py_0    defaults
jmespath                  0.10.0                     py_0    defaults
jpeg                      9d                   h0b31af3_0    conda-forge
jsonschema                3.2.0                    py38_1    defaults
jupyter_client            6.1.6                      py_0    defaults
jupyter_core              4.6.3                    py38_0    defaults
keyring                   21.3.0                   py38_0    defaults
lazy-object-proxy         1.4.3            py38h1de35cc_0    defaults
lcms2                     2.11                 h92f6f08_0    defaults
libcxx                    10.0.0                        1    defaults
libedit                   3.1.20191231         h1de35cc_1    defaults
libffi                    3.2.1                h0a44026_6    defaults
libiconv                  1.15              h0b31af3_1006    conda-forge
libpng                    1.6.37               ha441bb4_0    defaults
libsodium                 1.0.18               h1de35cc_0    defaults
libspatialindex           1.9.3                h0a44026_0    defaults
libtiff                   4.1.0                hcb84e12_1    defaults
libxcb                    1.13              h1de35cc_1002    conda-forge
libxml2                   2.9.10               h53d96d6_0    conda-forge
libxslt                   1.1.33               h320ff13_0    conda-forge
lxml                      4.5.2            py38hc829089_0    conda-forge
lz4-c                     1.9.2                hb1e8313_1    defaults
markupsafe                1.1.1            py38h1de35cc_1    defaults
mccabe                    0.6.1                    py38_1    defaults
mistune                   0.8.4           py38h1de35cc_1001    defaults
more-itertools            8.4.0                      py_0    defaults
nbconvert                 5.6.1                    py38_1    defaults
nbformat                  5.0.7                      py_0    defaults
ncurses                   6.2                  h0a44026_1    defaults
numpydoc                  1.1.0                      py_0    defaults
olefile                   0.46                       py_0    defaults
openssl                   1.1.1g               h1de35cc_0    defaults
packaging                 20.4                       py_0    defaults
pandoc                    2.10.1                        0    defaults
pandocfilters             1.4.2                    py38_1    defaults
pango                     1.42.4               haa940fe_4    conda-forge
parso                     0.5.2                      py_0    defaults
pathtools                 0.1.2                      py_1    defaults
pcre                      8.44                 hb1e8313_0    defaults
pexpect                   4.8.0                    py38_1    defaults
pickleshare               0.7.5                 py38_1001    defaults
pillow                    7.2.0            py38ha54b6ba_0    defaults
pip                       20.2.2                   py38_0    defaults
pixman                    0.38.0            h01d97ff_1003    conda-forge
pluggy                    0.13.1                   py38_0    defaults
prompt-toolkit            3.0.5                      py_0    defaults
psutil                    5.7.0            py38h1de35cc_0    defaults
pthread-stubs             0.3                  hdd91f34_1    defaults
ptyprocess                0.6.0                    py38_0    defaults
py                        1.9.0                      py_0    defaults
pycodestyle               2.6.0                      py_0    defaults
pycparser                 2.20                       py_2    defaults
pydocstyle                5.0.2                      py_0    defaults
pyflakes                  2.2.0                      py_0    defaults
pygments                  2.6.1                      py_0    defaults
pylint                    2.5.3                    py38_0    defaults
pyopenssl                 19.1.0                     py_1    defaults
pypandoc                  1.5                        py_0    defaults
pyparsing                 2.4.7                      py_0    defaults
pyphen                    0.9.5                      py_0    conda-forge
pyqt                      5.9.2            py38h655552a_2    defaults
pyrsistent                0.16.0           py38h1de35cc_0    defaults
pysocks                   1.7.1                    py38_1    defaults
pytest                    6.0.1                    py38_0    defaults
python                    3.8.5           cpython_h85f3143_0    conda-forge
python-dateutil           2.8.1                      py_0    defaults
python-jsonrpc-server     0.3.4                      py_1    defaults
python-language-server    0.31.9                   py38_0    defaults
python.app                2                       py38_10    defaults
python_abi                3.8                      1_cp38    conda-forge
pytz                      2020.1                     py_0    defaults
pyyaml                    5.3.1            py38haf1e3a3_1    defaults
pyzmq                     19.0.1           py38hb1e8313_1    defaults
qdarkstyle                2.8.1                      py_0    defaults
qt                        5.9.7                h8cf7e54_3    conda-forge
qtawesome                 0.7.2                      py_0    defaults
qtconsole                 4.7.5                      py_0    defaults
qtpy                      1.9.0                      py_0    defaults
readline                  8.0                  h1de35cc_0    defaults
requests                  2.24.0                     py_0    defaults
requests-file             1.5.1                      py_0    defaults
rope                      0.17.0                     py_0    defaults
rtree                     0.9.4                    py38_1    defaults
s3transfer                0.3.3                    py38_1    defaults
setuptools                49.6.0                   py38_0    defaults
sip                       4.19.8           py38h0a44026_0    defaults
six                       1.15.0                     py_0    defaults
snowballstemmer           2.0.0                      py_0    defaults
sortedcontainers          2.2.2                      py_0    defaults
sphinx                    3.2.1                      py_0    defaults
sphinxcontrib-applehelp   1.0.2                      py_0    defaults
sphinxcontrib-devhelp     1.0.2                      py_0    defaults
sphinxcontrib-htmlhelp    1.0.3                      py_0    defaults
sphinxcontrib-jsmath      1.0.1                      py_0    defaults
sphinxcontrib-qthelp      1.0.3                      py_0    defaults
sphinxcontrib-serializinghtml 1.1.4                      py_0    defaults
spyder                    4.1.3                    py38_0    defaults
spyder-kernels            1.9.3                    py38_0    defaults
spyder-unittest           0.4.1                      py_0    spyder-ide
sqlite                    3.32.3               hffcf06c_0    defaults
testpath                  0.4.4                      py_0    defaults
tinycss2                  1.0.2                      py_1    conda-forge
tk                        8.6.10               hb0a8c7a_0    defaults
tldextract                2.2.0                      py_0    conda-forge
toml                      0.10.1                     py_0    defaults
tornado                   6.0.4            py38h1de35cc_1    defaults
traitlets                 4.3.3                    py38_0    defaults
ujson                     1.35             py38h1de35cc_0    defaults
urllib3                   1.25.10                    py_0    defaults
watchdog                  0.10.3           py38haf1e3a3_0    defaults
wcwidth                   0.2.5                      py_0    defaults
weasyprint                51               py38hb084482_1    conda-forge
webencodings              0.5.1                    py38_1    defaults
wheel                     0.34.2                   py38_0    defaults
wrapt                     1.11.2           py38h1de35cc_0    defaults
wurlitzer                 2.0.1                    py38_0    defaults
xorg-kbproto              1.0.7             h1de35cc_1002    conda-forge
xorg-libx11               1.6.11               haf1e3a3_0    conda-forge
xorg-libxau               1.0.9                h1de35cc_0    conda-forge
xorg-libxdmcp             1.1.3                h01d97ff_0    conda-forge
xorg-libxext              1.3.4                h01d97ff_0    conda-forge
xorg-libxrender           0.9.10            h01d97ff_1002    conda-forge
xorg-renderproto          0.11.1            h1de35cc_1002    conda-forge
xorg-xextproto            7.3.0             h1de35cc_1002    conda-forge
xorg-xproto               7.0.31            h1de35cc_1007    conda-forge
xz                        5.2.5                h1de35cc_0    defaults
yaml                      0.2.5                haf1e3a3_0    defaults
yapf                      0.30.0                     py_0    defaults
zeromq                    4.3.2                hb1e8313_2    defaults
zipp                      3.1.0                      py_0    defaults
zlib                      1.2.11               h1de35cc_3    defaults
zstd                      1.4.5                h41d2c2f_0    defaults

@angloyna angloyna added source::community catch-all for issues filed by community members type::support neither a bug nor feature, is really just a user having questions or difficulty somewhere labels Aug 18, 2020
@BastianZim
Copy link
Contributor Author

Further info: The environmental variable was an email, maybe the @ is the problem?

@mrpcampos
Copy link

dont think so, i have the same problem with the GOOGLE_APPLICATION_CREDENTIALS var, where the value is just the path to the file

@williamcottrell72
Copy link

Having a similar issue where the environment variable has a "==" in it.

@IrfanAkram5
Copy link

IrfanAkram5 commented Jan 19, 2022

I messed up the setting of my environment variables when using conda env config vars set which caused an error message when deactivating an environment and unset was not fixing the issue.

Fixed issue by directly editing the value in pathToYourEnv/conda-meta/state . This stores the environment variables as a dictionary. Edit directly using vim or editor of your choice. My full travails here!

@AetherUnbound
Copy link

It appears that environment variables that are created for an environment using conda env config vars set <var> also attempt to get unset every time an environment is deactivated once conda env config vars unset is run. It also appears that an = is not necessary for setting an environment variable, as conda will interpret the value supplied as both the env var key AND value.

Both of these behaviors in conjunction create a situation where an invalid environment variable can be supplied once, unset, and then complain about the identifier being invalid every time the environment is activated.

Steps to reproduce

  1. Create and activate an environment
  2. Run conda env config vars set with an invalid bash environment variable name
  3. Deactivate and reactivate the environment (and observe the bash complaints)
  4. Unset the variable using conda env config vars unset
  5. Deactivate the environment
  6. Observe that on subsequent activations/deactivations, the former does not raise any complaints, but deactivations always complain about an invalid identifier.

Example:

$ conda create -y -n conda-test
Collecting package metadata (current_repodata.json): done
Solving environment: done


==> WARNING: A newer version of conda exists. <==
  current version: 4.10.3
  latest version: 4.11.0

Please update conda by running

    $ conda update -n base -c defaults conda



## Package Plan ##

  environment location: /home/madison/programs/anaconda3/envs/conda-test



Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
#     $ conda activate conda-test
#
# To deactivate an active environment, use
#
#     $ conda deactivate


$ vact conda-test 

$ conda env config vars set not::valid::identifier
To make your changes take effect please reactivate your environment

$ deac
bash: unset: `not::valid::identifier': not a valid identifier

$ vact conda-test 
bash: export: `NOT::VALID::IDENTIFIER=not::valid::identifier': not a valid identifier

$ conda env config vars unset not::valid::identifier
To make your changes take effect please reactivate your environment

$ conda env config vars list

$ deac
bash: unset: `not::valid::identifier': not a valid identifier

(here vact and deac are short for the activation/deactivation commands respectively)

Similar to @IrfanAkram5, the only way I was able to get these complaints to go away was manually editing the conda-meta/state file and removing the entry for the invalid key.

@github-actions
Copy link

Hi there, thank you for your contribution!

This issue has been automatically marked as stale because it has not had recent activity. It will be closed automatically if no further activity occurs.

If you would like this issue to remain open please:

  1. Verify that you can still reproduce the issue at hand
  2. Comment that the issue is still reproducible and include:
    - What OS and version you reproduced the issue on
    - What steps you followed to reproduce the issue

NOTE: If this issue was closed prematurely, please leave a comment.

Thanks!

@github-actions github-actions bot added the stale [bot] marked as stale due to inactivity label Mar 30, 2022
@AetherUnbound
Copy link

This issue still persists using the instructions I described above.

@BastianZim
Copy link
Contributor Author

Not stale

@github-actions github-actions bot added stale::recovered [bot] recovered after being marked as stale and removed stale [bot] marked as stale due to inactivity labels Mar 31, 2022
@kenodegard kenodegard added type::bug describes erroneous operation, use severity::* to classify the type type::feature request for a new feature or capability severity::2 critical; broken functionality with an unacceptably complex workaround backlog issue has been triaged but has not been earmarked for any upcoming release and removed type::support neither a bug nor feature, is really just a user having questions or difficulty somewhere labels Aug 16, 2022
@kenodegard
Copy link
Contributor

conda env config vars set NAME=value will update conda-meta/state for the active environment:

{"env_vars": {"NAME": "value"}}

conda env config vars unset NAME on the other hand is not the opposite, it updates conda-meta/state to explicitly unset the variable upon activation:

{"env_vars": {"NAME": "***unset***"}}

If you need to remove a previously configured environment variable please modify the state file.

@travishathaway travishathaway removed the type::feature request for a new feature or capability label Sep 15, 2023
@joshred83
Copy link

What's the proper way to modify the state file?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog issue has been triaged but has not been earmarked for any upcoming release severity::2 critical; broken functionality with an unacceptably complex workaround source::community catch-all for issues filed by community members stale::recovered [bot] recovered after being marked as stale type::bug describes erroneous operation, use severity::* to classify the type
Projects
Status: No status
Development

No branches or pull requests

9 participants