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

conda 4.6.14 needs additional escaping of "!=" on Windows command line #8588

Open
mstimberg opened this issue Apr 23, 2019 · 3 comments
Open
Labels
stale::recovered [bot] recovered after being marked as stale

Comments

@mstimberg
Copy link
Contributor

As part of package match specifications, users can use != to exclude a specific version. In conda versions up to 4.6.12, the != did not need any escaping on the Windows command line. Optionally, escaping could be used for consistency with other operators such as >=. For example, the following commands all installed a sympy version different from 1.1.0:

conda install sympy!=1.1.0
conda install "sympy!=1.1.0"
conda install sympy^!=1.1.0

With conda 4.6.14, all of the above will instead interpret the package match specification as sympy=1.1.0, i.e. install the exact version that the user wanted to exclude. The workaround is to escape the exclamation mark twice, i.e. the following correctly excludes version 1.1.0:

conda install "sympy^!=1.1.0"`

However, this specification will not work with older versions of conda.

I have very limited experience with Windows batch files, but I think it has to do with commit 2b7c8ec which introduced @SETLOCAL EnableDelayedExpansion into conda.bat:

@SETLOCAL EnableDelayedExpansion

Steps to Reproduce

(base) C:\Users\Marcel>conda create -n conda_test "sympy!=1.1.0"
Collecting package metadata: done
Solving environment: done

## Package Plan ##

  environment location: C:\Users\Marcel\Miniconda3\envs\conda_test

  added / updated specs:
    - sympy=1.1.0


The following NEW packages will be INSTALLED:

  certifi            pkgs/main/win-64::certifi-2019.3.9-py36_0
  mpmath             pkgs/main/win-64::mpmath-1.1.0-py36_0
  pip                pkgs/main/win-64::pip-19.0.3-py36_0
  python             pkgs/main/win-64::python-3.6.8-h9f7ef89_7
  setuptools         pkgs/main/win-64::setuptools-41.0.0-py36_0
  sqlite             pkgs/main/win-64::sqlite-3.28.0-he774522_0
  sympy              pkgs/free/win-64::sympy-1.1-py36_0
  vc                 pkgs/main/win-64::vc-14.1-h0510ff6_4
  vs2015_runtime     pkgs/main/win-64::vs2015_runtime-14.15.26706-h3a45250_0
  wheel              pkgs/main/win-64::wheel-0.33.1-py36_0
  wincertstore       pkgs/main/win-64::wincertstore-0.2-py36h7fe50ca_0

Expected Behavior

A new environment with a sympy version not equal to version 1.1.0 should be created; instead, the environment installs this very version.

Environment Information

`conda info`

     active environment : base
    active env location : C:\Users\Marcel\Miniconda3
            shell level : 1
       user config file : C:\Users\Marcel\.condarc
 populated config files : C:\Users\Marcel\.condarc
          conda version : 4.6.14
    conda-build version : 3.17.8
         python version : 3.7.1.final.0
       base environment : C:\Users\Marcel\Miniconda3  (writable)
           channel URLs : https://conda.anaconda.org/brian-team/win-64
                          https://conda.anaconda.org/brian-team/noarch
                          https://repo.anaconda.com/pkgs/main/win-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/free/win-64
                          https://repo.anaconda.com/pkgs/free/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
          package cache : C:\Users\Marcel\Miniconda3\pkgs
                          C:\Users\Marcel\.conda\pkgs
                          C:\Users\Marcel\AppData\Local\conda\conda\pkgs
       envs directories : C:\Users\Marcel\Miniconda3\envs
                          C:\Users\Marcel\.conda\envs
                          C:\Users\Marcel\AppData\Local\conda\conda\envs
               platform : win-64
             user-agent : conda/4.6.14 requests/2.21.0 CPython/3.7.1 Windows/7 Windows/6.1.7601
          administrator : False
             netrc file : None
           offline mode : False

@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 May 16, 2022
@h-vetinari
Copy link

Still an issue. Just updated my environment and picked one of the packages that got upgraded (e.g. filelock 3.6 -> 3.7). Actually, it's even worse because now the work-around doesn't work anymore.

conda install filelock!=3.7.0
conda install filelock^!=3.7.0
conda install "filelock!=3.7.0"

all do not pick up the downgrade. The workaround now fails

conda install "filelock^!=3.7.0"
[...]
PackagesNotFoundError: The following packages are not available from current channels:

  - filelock^^=3.7.0

It seems that exclamation marks are being stripped completely.

conda install "filelock^!!=3.7.0"
[...]
PackagesNotFoundError: The following packages are not available from current channels:

  - filelock^^=3.7.0

or

conda install "filelock^^!=3.7.0"
[...]
PackagesNotFoundError: The following packages are not available from current channels:

  - filelock^^^^=3.7.0

My setup is:

conda info

     active environment : base
    active env location : C:\Users\[...]\.conda\envs\builder
            shell level : 1
       user config file : C:\Users\[...]\.condarc
 populated config files : C:\Users\[...]\.condarc
          conda version : 4.12.0
    conda-build version : 3.21.8
         python version : 3.9.12.final.0
       virtual packages : __cuda=11.4=0
                          __win=0=0
                          __archspec=1=x86_64
       base environment : C:\Users\[...]\.conda\envs\builder  (writable)
      conda av data dir : C:\Users\[...]\.conda\envs\builder\etc\conda
  conda av metadata url : None
           channel URLs : https://conda.anaconda.org/conda-forge/win-64
                          https://conda.anaconda.org/conda-forge/noarch
                          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
          package cache : C:\Users\[...]\.conda\envs\builder\pkgs
                          C:\Users\[...]\.conda\pkgs
                          C:\Users\[...]\AppData\Local\conda\conda\pkgs
       envs directories : C:\Users\[...]\.conda\envs\builder\envs
                          C:\Users\[...]\.conda\envs
                          C:\Users\[...]\AppData\Local\conda\conda\envs
               platform : win-64
             user-agent : conda/4.12.0 requests/2.27.1 CPython/3.9.12 Windows/10 Windows/10.0.19044
          administrator : False
             netrc file : None
           offline mode : False

@mstimberg
Copy link
Contributor Author

I can confirm that this is still an issue with conda 4.12 – maybe != isn't supposed to be supported anymore and should no longer be mentioned in the documentation? It appears to still work under Linux, though...
As @h-vetinari observed, the workaround I mentioned earlier does no longer work. If I am not mistaken, the only way to exclude a specific version at the moment is to ask for a version that is smaller or greater than the respective version, e.g. conda install "sympy<1.1.0|>1.1.0" for the example I used in my initial post.

@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 May 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale::recovered [bot] recovered after being marked as stale
Projects
Status: 🆕 New
Development

No branches or pull requests

2 participants