mamba-org / mamba

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

BUG: Micromamba ignores conda env variable `subdir=osx-64` causing change in behaviour compared to mamba #2684

Open corneliusroemer opened 1 year ago

corneliusroemer commented 1 year ago

Troubleshooting docs

How did you install Mamba?

Mambaforge

Search tried in issue tracker

Maybe related: https://github.com/mamba-org/mamba/issues/1901

Latest version of Mamba

Tried in Conda?

I do not have this problem with Conda, just with Mamba

Describe your issue

I recently switched from mamba to micromamba.

There seems to be a very important subtle mismatch in behaviour that I only recently noticed: micromamba seems to ignore the value of the environment variable set via conda config --env --set subdir osx-64.

I need this env variable as I have osx-64 environments. When I used mamba this worked perfectly. However, now, after the switch to micromamba (aliased to mamba) this suddenly produces subtle errors.

To me this seems like a bug: micromamba should respect those environment variables, or at least warn the user that it's ignoring those variables (though it knows they exist).

Why is this important? conda config --env --set subdir osx-64 is plastered all over StackOverflow (and elswhere) for how to use osx-64 environments on M1 mac. Many people will run into this issue if they think micromamba behaves like mamba. See [1] [2] [3] [4]

mamba info / micromamba info

$ /opt/homebrew/bin/micromamba info
       libmamba version : 1.4.9
     micromamba version : 1.4.9
           curl version : libcurl/7.88.1 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.11 nghttp2/1.51.0
     libarchive version : libarchive 3.5.3 zlib/1.2.11 liblzma/5.0.5 bz2lib/1.0.8
       envs directories : /Users/corneliusromer/micromamba/envs
          package cache : /Users/corneliusromer/micromamba/pkgs
                          /Users/corneliusromer/.mamba/pkgs
            environment : /opt/homebrew/Caskroom/miniforge/base/envs/nextstrain (active)
           env location : /opt/homebrew/Caskroom/miniforge/base/envs/nextstrain
      user config files : /Users/corneliusromer/.mambarc
 populated config files : /opt/homebrew/Caskroom/miniforge/base/envs/nextstrain/.condarc
                          /Users/corneliusromer/.mambarc
                          /Users/corneliusromer/.condarc
       virtual packages : __unix=0=0
                          __osx=13.4.1=0
                          __archspec=1=arm64
               channels : https://conda.anaconda.org/conda-forge/osx-arm64
                          https://conda.anaconda.org/conda-forge/noarch
                          https://conda.anaconda.org/bioconda/osx-arm64
                          https://conda.anaconda.org/bioconda/noarch
                          https://repo.anaconda.com/pkgs/main/osx-arm64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/osx-arm64
                          https://repo.anaconda.com/pkgs/r/noarch
       base environment : /Users/corneliusromer/micromamba
               platform : osx-arm64

$ /opt/homebrew/Caskroom/miniforge/base/envs/nextstrain/bin/mamba info
/opt/homebrew/Caskroom/miniforge/base/envs/nextstrain/lib/python3.10/site-packages/conda_package_streaming/package_streaming.py:19: UserWarning: zstandard could not be imported. Running without .conda support.
  warnings.warn("zstandard could not be imported. Running without .conda support.")
/opt/homebrew/Caskroom/miniforge/base/envs/nextstrain/lib/python3.10/site-packages/conda_package_handling/api.py:29: UserWarning: Install zstandard Python bindings for .conda support
  _warnings.warn("Install zstandard Python bindings for .conda support")
Traceback (most recent call last):
  File "/opt/homebrew/Caskroom/miniforge/base/envs/nextstrain/bin/mamba", line 7, in <module>
    from mamba.mamba import main
  File "/opt/homebrew/Caskroom/miniforge/base/envs/nextstrain/lib/python3.10/site-packages/mamba/mamba.py", line 49, in <module>
    import libmambapy as api
  File "/opt/homebrew/Caskroom/miniforge/base/envs/nextstrain/lib/python3.10/site-packages/libmambapy/__init__.py", line 7, in <module>
    raise e
  File "/opt/homebrew/Caskroom/miniforge/base/envs/nextstrain/lib/python3.10/site-packages/libmambapy/__init__.py", line 4, in <module>
    from libmambapy.bindings import *  # noqa: F401,F403
ImportError: dlopen(/opt/homebrew/Caskroom/miniforge/base/envs/nextstrain/lib/python3.10/site-packages/libmambapy/bindings.cpython-310-darwin.so, 0x0002): Library not loaded: @rpath/libsolv.1.dylib
  Referenced from: <9E9B973C-982E-3042-8B4C-7CEAC439148C> /opt/homebrew/Caskroom/miniforge/base/envs/nextstrain/lib/python3.10/site-packages/libmambapy/bindings.cpython-310-darwin.so
  Reason: tried: '/opt/homebrew/Caskroom/miniforge/base/envs/nextstrain/lib/python3.10/site-packages/libmambapy/../../../libsolv.1.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/opt/homebrew/Caskroom/miniforge/base/envs/nextstrain/lib/python3.10/site-packages/libmambapy/../../../libsolv.1.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/opt/homebrew/Caskroom/miniforge/base/envs/nextstrain/bin/../lib/libsolv.1.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/opt/homebrew/Caskroom/miniforge/base/envs/nextstrain/bin/../lib/libsolv.1.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/usr/local/lib/libsolv.1.dylib' (no such file), '/usr/lib/libsolv.1.dylib' (no such file, not in dyld cache)

Logs

No response

environment.yml

No response

~/.condarc

$ cat ~/.condarc
changeps1: false
auto_activate_base: false
report_errors: true
channels:
  - bioconda
  - conda-forge
  - defaults
channel_priority: strict
update_dependencies: true
download_threads: 20
repodata_use_zst: true
subdir: osx-arm64

$  cat ~/.mambarc                                                             
repodata_use_zst: true
wolfv commented 1 year ago

I think using CONDA_SUBDIR=osx-64 should work, and --platform=osx-64 should also work for micromamba (which is a micromamba extension, basically).

We could start supporting the subdir config value as well.

corneliusroemer commented 1 year ago

I seem to be getting it to work with --platform=osx-64 as recommended in linked issue, env variable is a great tip as well.

I just thought it'd be good to flag this so you can see whether it may be worth warning, and maybe supporting subdir for compatibility.

Interestingly, it seems micromamba can install noarch osx-64 packages from bioconda into an arm64 environment. This is something that mamba didn't support. Very neat! This will allow me to do away with using translated (~2x slower) environments for environments that require noarch bioconda packages only (and not osx-64 bioconda packages)

jonashaag commented 1 year ago

I would assume that this is relatively easy to fix by extending the configuration code accordingly