conda / conda-lock

Lightweight lockfile for conda environments
https://conda.github.io/conda-lock/
Other
456 stars 101 forks source link

--update with --micromamba drops architecture from other packages #625

Closed benmoss closed 2 months ago

benmoss commented 2 months ago

Checklist

What happened?

Given these environment.yml and conda-lock.yml files, running conda-lock lock --platform linux-64 --update bokeh --micromamba results in conda-lock updating the URL for every package other than bokeh to no longer have /noarch or /linux-64 in their URLs. Here's the diff of conda-lock.yml on my machine.

The same bug doesn't happen without --update or without --micromamba.

Conda Info

✗ micromamba info

       libmamba version : 1.5.8
     micromamba version : 1.5.8
           curl version : libcurl/8.4.0 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.12 nghttp2/1.58.0
     libarchive version : libarchive 3.5.3 zlib/1.2.12 liblzma/5.4.3 bz2lib/1.0.8
       envs directories : /Users/bmoss40/workspace/micromamba/envs
          package cache : /Users/bmoss40/workspace/micromamba/pkgs
                          /Users/bmoss40/.mamba/pkgs
            environment : pangeo (active)
           env location : /Users/bmoss40/workspace/micromamba/envs/pangeo
      user config files : /Users/bmoss40/.mambarc
 populated config files : /Users/bmoss40/.condarc
       virtual packages : __unix=0=0
                          __osx=14.4.1=0
                          __archspec=1=arm64
               channels : conda-forge
       base environment : /Users/bmoss40/workspace/micromamba
               platform : osx-arm64

✗ conda-lock --version
conda-lock, version 2.5.6

### Conda Config

```shell
I don't think this is relevant but let me know :)

Conda list

I don't think this is relevant but let me know :)

Additional Context

No response

maresb commented 2 months ago

Wow, nice catch! :grin:

Here is the offending block of code:

https://github.com/conda/conda-lock/blob/d0a8a7b73dec3782291b0124b04d6a003862c530/conda_lock/conda_solver.py#L509-L513

which hasn't been touched since its original inclusion 2½ years ago here.

Why is it like this? Because back then Micromamba was on v0.17.0 and contained a bug where if you run micromamba list --json it would incorrectly append the platform to base_url.

The bug was fixed here and released in Micromamba v0.22.0, triggering the bug you just discovered.

It's a pretty weird that nobody has reported this in the past two years, but better late than never.

This should be pretty straightforward to fix...

benmoss commented 2 months ago

Probably just that the constellation of factors required to hit this bug is narrow enough that nobody hit it before! Thanks for the quick fix!