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

Setting an environment variable does not work when value contains a dollar sign $ #10126

Open
gregmuellegger opened this issue Aug 4, 2020 · 2 comments
Labels
source::community catch-all for issues filed by community members stale::recovered [bot] recovered after being marked as stale

Comments

@gregmuellegger
Copy link

gregmuellegger commented Aug 4, 2020

Current Behavior

When setting an environment variable that contains a dollar sign $ using conda env config vars set MYVAR='some$value' (tested on Windows PowerShell) then:

  • Deactivating the environment shows an error
  • Listing the variables with conda env config vars list actually works and shows the correct content
  • Using the environment variable, e.g. from python, reveals that the contents is set inproperly

See the demo below.

Steps to Reproduce

(base) PS C:\Users\muellegger> conda create -n tmp python
...
(base) PS C:\Users\muellegger> conda activate tmp
(tmp) PS C:\Users\muellegger> conda env config vars set MYVAR='some$value'
To make your changes take effect please reactivate your environment
(tmp) PS C:\Users\muellegger> conda deactivate
Remove-Item : Der Pfad "Env:\MYVAR" kann nicht gefunden werden, da er nicht vorhanden ist.
In Zeile:3 Zeichen:1
+ Remove-Item Env:/MYVAR
+ ~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Env:\MYVAR:String) [Remove-Item], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.RemoveItemCommand

(base) PS C:\Users\muellegger> conda activate tmp
(tmp) PS C:\Users\muellegger> conda env config vars list
MYVAR = some$value
(tmp) PS C:\Users\muellegger> python
Python 3.8.5 (default, Aug  3 2020, 11:07:58) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.environ["MYVAR"]
'some'
>>>

Expected Behavior

The script responsible for setting the environment variables should escape the values contained properly to not conflict with special shell characters.

Environment Information

`conda info`

     active environment : tmp
    active env location : C:\Users\muellegger\AppData\Local\Continuum\anaconda3\envs\tmp
            shell level : 2
       user config file : C:\Users\muellegger\.condarc
 populated config files : C:\Users\muellegger\.condarc
          conda version : 4.8.3
    conda-build version : 3.18.8
         python version : 3.7.3.final.0
       virtual packages : __cuda=10.2
       base environment : C:\Users\muellegger\AppData\Local\Continuum\anaconda3  (writable)
           channel URLs : https://repo.anaconda.com/pkgs/main/win-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/win-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/msys2/win-64
                          https://repo.anaconda.com/pkgs/msys2/noarch
                          https://conda.anaconda.org/conda-forge/win-64
                          https://conda.anaconda.org/conda-forge/noarch
          package cache : C:\Users\muellegger\AppData\Local\Continuum\anaconda3\pkgs
                          C:\Users\muellegger\.conda\pkgs
                          C:\Users\muellegger\AppData\Local\conda\conda\pkgs
       envs directories : C:\Users\muellegger\AppData\Local\Continuum\anaconda3\envs
                          C:\Users\muellegger\.conda\envs
                          C:\Users\muellegger\AppData\Local\conda\conda\envs
               platform : win-64
             user-agent : conda/4.8.3 requests/2.22.0 CPython/3.7.3 Windows/10 Windows/10.0.19041
          administrator : False
             netrc file : None
           offline mode : False

`conda config --show-sources`

==> C:\Users\muellegger\.condarc <==
ssl_verify: True
channels:
  - defaults
  - conda-forge
report_errors: False

`conda list --show-channel-urls`

# packages in environment at C:\Users\muellegger\AppData\Local\Continuum\anaconda3\envs\tmp:
#
# Name                    Version                   Build  Channel
ca-certificates           2020.6.24                     0    defaults
certifi                   2020.6.20                py38_0    defaults
openssl                   1.1.1g               he774522_0    defaults
pip                       20.1.1                   py38_1    defaults
python                    3.8.5                he1778fa_0    defaults
setuptools                49.2.0                   py38_0    defaults
sqlite                    3.32.3               h2a8f88b_0    defaults
vc                        14.1                 h0510ff6_4    defaults
vs2015_runtime            14.16.27012          hf0eaf9b_3    defaults
wheel                     0.34.2                   py38_0    defaults
wincertstore              0.2                      py38_0    defaults
zlib                      1.2.11               h62dcd97_4    defaults

@angloyna angloyna added the source::community catch-all for issues filed by community members label Aug 4, 2020
@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 Jan 21, 2023
@jaimergp
Copy link
Contributor

Still relevant.

@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 Feb 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
source::community catch-all for issues filed by community members stale::recovered [bot] recovered after being marked as stale
Projects
Status: 🆕 New
Development

No branches or pull requests

3 participants