mamba-org / mamba

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

Micromamba parses condarc YAML with <CR> line breaks incorrectly #3401

Open HedgehogCode opened 1 month ago

HedgehogCode commented 1 month ago

Troubleshooting docs

Anaconda default channels

How did you install Mamba?

Micromamba

Search tried in issue tracker

yes

Latest version of Mamba

Tried in Conda?

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

Describe your issue

If the .condarc file uses only the \<CR> character as line breaks (without a following \<LF>) the settings are not correctly parsed causing errors.

Try the following Python script for creating such a .condarc file:

yaml_content = (
    "default_channels:\r"
    "- https://foo.bar/my-channel\r"
    "- https://foo.bar/my-second-channel\r"
)
with open("condarc_with_CR.yaml", "w", newline="") as file:
    file.write(yaml_content)

# NB: Loading this with PyYAML works fine
from yaml import load, Loader, CLoader
print("Loader:", load(yaml_content, Loader))
print("CLoader:", load(yaml_content, CLoader))

Using the output of this file as the .condarc causes the following error:

% ./micromamba create -p ./foo -c conda-forge python
critical libmamba Failed to parse URL "https://foo.bar/my-channel - https://foo.bar/my-second-channel": Malformed input to a URL function

Note, that the YAML Specification allows using only \<CR> for line endings and conda handles them correctly. This might be related to https://github.com/jbeder/yaml-cpp/issues/986.

mamba info / micromamba info

% micromamba info # executed without the critical `.condarc` file to get an output
       libmamba version : 2.0.0
 micromamba-2rc version : 2.0.0
           curl version : libcurl/8.9.1 OpenSSL/3.3.1 zlib/1.3.1 zstd/1.5.6 libssh2/1.11.0 nghttp2/1.58.0
     libarchive version : libarchive 3.7.4 zlib/1.2.13 bz2lib/1.0.8 libzstd/1.5.6
       envs directories : /home/benjamin/.local/share/mamba/envs
          package cache : /home/benjamin/.local/share/mamba/pkgs
                          /home/benjamin/.mamba/pkgs
            environment : /home/benjamin/miniconda3 (active)
           env location : /home/benjamin/miniconda3
      user config files : /home/benjamin/.mambarc
 populated config files : /home/benjamin/.condarc
       virtual packages : __unix=0=0
                          __linux=6.5.0=0
                          __glibc=2.35=0
                          __archspec=1=x86_64-v3
               channels : https://conda.anaconda.org/conda-forge/linux-64
                          https://conda.anaconda.org/conda-forge/noarch
       base environment : /home/benjamin/.local/share/mamba
               platform : linux-64

Logs

% ./micromamba create -v -p ./foo -c conda-forge python
critical libmamba Failed to parse URL "https://foo.bar/my-channel - https://foo.bar/my-second-channel": Malformed input to a URL function

environment.yml

No response

~/.condarc

Note that this does not reflect the line endings of the real file. See the ticket description.

default_channels:
- https://foo.bar/my-channel
- https://foo.bar/my-second-channel
Hind-M commented 1 month ago

cf. https://github.com/jbeder/yaml-cpp/issues/1309