mamba-org / mamba

The Fast Cross-Platform Package Manager
https://mamba.readthedocs.io
BSD 3-Clause "New" or "Revised" License
6.57k stars 343 forks source link

`UnSolvable.explain_problems()` fails if the conflict involves a pinned package and the request has `flags.allow_uninstall=False` #3267

Closed jaimergp closed 3 months ago

jaimergp commented 3 months ago

Troubleshooting docs

Anaconda default channels

How did you install Mamba?

Mambaforge or latest Miniforge

Search tried in issue tracker

Found invalid version predicate in

Latest version of Mamba

Tried in Conda?

Not applicable

Describe your issue

If a conflict involves a pinned package (e.g. python) and flags.allow_uninstall=False, unsolvable.explain_problems() fails with libmambapy.bindings.specs.ParseError: Found invalid version predicate in "on python".

Reproducer with Python ```python import libmambapy db = libmambapy.solver.libsolv.Database( libmambapy.specs.ChannelResolveParams( channel_alias=libmambapy.specs.CondaURL.parse("https://conda.anaconda.org") ) ) print("loading repodata") repos = [ db.add_repo_from_repodata_json( path="/opt/conda/pkgs/cache/d9d93fba.json", # taken from the pkgs/cache url="https://conda.anaconda.org/conda-forge/linux-aarch64", channel_id="conda-forge", ), db.add_repo_from_repodata_json( path="/opt/conda/pkgs/cache/09cdf8bf.json", # taken from the pkgs/cache url="https://conda.anaconda.org/conda-forge/noarch", channel_id="conda-forge", ), ] Request = libmambapy.solver.Request MatchSpec = libmambapy.specs.MatchSpec print("crafting request...") request = Request( jobs=[ Request.Pin(MatchSpec.parse("python=3.12")), Request.Install(MatchSpec.parse("numpy=*=*py27*")), ], flags=Request.Flags( allow_downgrade=True, allow_uninstall=False, force_reinstall=False, keep_dependencies=True, keep_user_specs=True, order_request=False, # we do this ourselves strict_repo_priority=True, ), ) print("solving...") solver = libmambapy.solver.libsolv.Solver() outcome = solver.solve(db, request) if isinstance(outcome, libmambapy.solver.libsolv.UnSolvable): print(outcome.explain_problems(db, libmambapy.Palette.no_color())) else: print("OK!") ```

mamba info / micromamba info

libmamba version : 2.0.0
          mamba version : 2.0.0
           curl version : libcurl/8.7.1 OpenSSL/3.2.1 zlib/1.2.13 zstd/1.5.5 libssh2/1.11.0 nghttp2/1.58.0
     libarchive version : libarchive 3.7.2 zlib/1.2.13 liblzma/5.2.6 bz2lib/1.0.8 liblz4/1.9.3 libzstd/1.5.5
       envs directories : /root/.local/share/mamba/envs
          package cache : /root/.local/share/mamba/pkgs
                          /root/.mamba/pkgs
            environment : /opt/conda (active)
           env location : /opt/conda
      user config files : /root/.mambarc
 populated config files : /opt/conda/.condarc
       virtual packages : __unix=0=0
                          __linux=5.15.49=0
                          __glibc=2.31=0
                          __archspec=1=aarch64
               channels : https://conda.anaconda.org/conda-forge/linux-aarch64
                          https://conda.anaconda.org/conda-forge/noarch
       base environment : /root/.local/share/mamba
               platform : linux-aarch64

Logs

No response

environment.yml

No response

~/.condarc

No response