Repository: mamba-org/mamba (C++)

Issue:
[Bug] `mamba` resolves wrong channels when users set `custom_channels` in `condarc`
### Troubleshooting docs

- [X] My problem is not solved in the Troubleshooting docs

### Search tried in issue tracker

#2179

### Latest version of Mamba

- [X] My problem is not solved with the latest version

### Tried in Conda?

Not reproducible with Conda

### Describe your issue

I set custom channel URLs in my `condarc` with geolocalized mirrors to speed up downloading. I also set `force_reinstall: true` in my `condarc` to always make a new installation.

```yaml
channels:
  - pytorch
  - defaults
  - conda-forge
default_channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
  conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
channel_priority: flexible

ssl_verify: true
show_channel_urls: false
report_errors: false

force_reinstall: true
```

While running:

```bash
mamba create -n test pytorch::pytorch -y
```

it fails to create the environment. I got:

<details>
<summary>Output of `mamba create -n test pytorch::pytorch -y`</summary>

```text

                  __    __    __    __
                 /  \  /  \  /  \  /  \
                /    \/    \/    \/    \
███████████████/  /██/  /██/  /██/  /████████████████████████
              /  / \   / \   / \   / \  \____
             /  /   \_/   \_/   \_/   \    o \__,
            / _/                       \_____/  `
            |/
        ███╗   ███╗ █████╗ ███╗   ███╗██████╗  █████╗
        ████╗ ████║██╔══██╗████╗ ████║██╔══██╗██╔══██╗
        ██╔████╔██║███████║██╔████╔██║██████╔╝███████║
        ██║╚██╔╝██║██╔══██║██║╚██╔╝██║██╔══██╗██╔══██║
        ██║ ╚═╝ ██║██║  ██║██║ ╚═╝ ██║██████╔╝██║  ██║
        ╚═╝     ╚═╝╚═╝  ╚═╝╚═╝     ╚═╝╚═════╝ ╚═╝  ╚═╝

        mamba (1.1.0) supported by @QuantStack

        GitHub:  https://github.com/mamba-org/mamba
        Twitter: https://twitter.com/QuantStack

█████████████████████████████████████████████████████████████


Looking for: ['pytorch::pytorch']

pytorch/linux-64                                              No change
pytorch/noarch                                                No change
anaconda/pkgs/main/noarch                                     No change
anaconda/pkgs/r/linux-64                                      No change
anaconda/pkgs/main/linux-64                                   No change
anaconda/pkgs/msys2/noarch                                    No change
conda-forge/linux-64                                          No change
conda-forge/noarch                                            No change
anaconda/pkgs/r/noarch                                        No change
https://mirrors.tuna.tsinghua.edu.cn/anaconda/cl..            No change
anaconda/pkgs/msys2/linux-64                                  No change
https://mirrors.tuna.tsinghua.edu.cn/anaconda/cl..            No change
Transaction

  Prefix: /home/PanXuehai/Miniconda3/envs/test

  Updating specs:

   - pytorch::pytorch


  Package                 Version  Build            Channel                                                            Size
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
  Install:
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

  + _libgcc_mutex             0.1  main             mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64         Cached
  + _openmp_mutex             5.1  1_gnu            mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64         Cached
  + blas                      1.0  mkl              mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64         Cached
  + bzip2                   1.0.8  h7b6447c_0       mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64         Cached
  + ca-certificates    2022.10.11  h06a4308_0       mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64         Cached
  + certifi             2022.12.7  py310h06a4308_0  mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64         Cached
  + flit-core               3.6.0  pyhd3eb1b0_0     mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/noarch           Cached
  + intel-openmp         2022.1.0  h9e868ea_3769    mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64            5MB
  + ld_impl_linux-64         2.38  h1181459_1       mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64         Cached
  + libffi                  3.4.2  h6a678d5_6       mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64         Cached
  + libgcc-ng              11.2.0  h1234567_1       mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64         Cached
  + libgomp                11.2.0  h1234567_1       mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64         Cached
  + libstdcxx-ng           11.2.0  h1234567_1       mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64         Cached
  + libuuid                1.41.5  h5eee18b_0       mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64         Cached
  + mkl                  2022.1.0  hc2b9512_224     mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64          136MB
  + ncurses                   6.3  h5eee18b_3       mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64         Cached
  + openssl                1.1.1s  h7f8727e_0       mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64         Cached
  + pip                    22.3.1  py310h06a4308_0  mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64         Cached
  + python                 3.10.8  h7a1cb2a_1       mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64         Cached
  + pytorch                1.13.1  py3.10_cpu_0     mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/linux-64     Cached
  + pytorch-mutex             1.0  cpu              mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/noarch       Cached
  + readline                  8.2  h5eee18b_0       mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64         Cached
  + setuptools             65.5.0  py310h06a4308_0  mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64         Cached
  + sqlite                 3.40.0  h5082296_0       mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64         Cached
  + tk                     8.6.12  h1ccaba5_0       mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64         Cached
  + typing_extensions       4.4.0  py310h06a4308_0  mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64         Cached
  + tzdata                  2022g  h04d1e81_0       mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/noarch           Cached
  + wheel                  0.37.1  pyhd3eb1b0_0     mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/noarch           Cached
  + xz                      5.2.8  h5eee18b_0       mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64         Cached
  + zlib                   1.2.13  h5eee18b_0       mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64         Cached

  Summary:

  Install: 30 packages

  Total download: 141MB

─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────


intel-openmp                                         4.7MB @   1.9MB/s  2.5s
mkl                                                136.0MB @   3.6MB/s 37.7s


# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<

    Traceback (most recent call last):
      File "/home/PanXuehai/Miniconda3/lib/python3.9/site-packages/conda/exceptions.py", line 1118, in __call__
        return func(*args, **kwargs)
      File "/home/PanXuehai/Miniconda3/lib/python3.9/site-packages/mamba/mamba.py", line 936, in exception_converter
        raise e
      File "/home/PanXuehai/Miniconda3/lib/python3.9/site-packages/mamba/mamba.py", line 929, in exception_converter
        exit_code = _wrapped_main(*args, **kwargs)
      File "/home/PanXuehai/Miniconda3/lib/python3.9/site-packages/mamba/mamba.py", line 887, in _wrapped_main
        result = do_call(parsed_args, p)
      File "/home/PanXuehai/Miniconda3/lib/python3.9/site-packages/mamba/mamba.py", line 754, in do_call
        exit_code = create(args, parser)
      File "/home/PanXuehai/Miniconda3/lib/python3.9/site-packages/mamba/mamba.py", line 630, in create
        return install(args, parser, "create")
      File "/home/PanXuehai/Miniconda3/lib/python3.9/site-packages/mamba/mamba.py", line 588, in install
        conda_transaction = to_txn(
      File "/home/PanXuehai/Miniconda3/lib/python3.9/site-packages/mamba/utils.py", line 443, in to_txn
        return to_txn_precs(
      File "/home/PanXuehai/Miniconda3/lib/python3.9/site-packages/mamba/utils.py", line 406, in to_txn_precs
        unlink_precs, link_precs = diff_for_unlink_link_precs(
      File "/home/PanXuehai/Miniconda3/lib/python3.9/site-packages/conda/core/solve.py", line 1172, in diff_for_unlink_link_precs
        assert prec
    AssertionError

`$ /home/PanXuehai/Miniconda3/bin/mamba create -n test pytorch::pytorch -y`

  environment variables:
                ALL_PROXY=<set>
                 CIO_TEST=<not set>
                CONDA_EXE=/home/PanXuehai/Miniconda3/bin/conda
   CONDA_PYTHONBREAKPOINT=
         CONDA_PYTHON_EXE=/home/PanXuehai/Miniconda3/bin/python
               CONDA_ROOT=/home/PanXuehai/Miniconda3
              CONDA_SHLVL=0
       CPLUS_INCLUDE_PATH=/usr/local/cuda-11.7/include:/usr/local/cuda-11.7/extras/CUPTI/include
           CURL_CA_BUNDLE=<not set>
           C_INCLUDE_PATH=/usr/local/cuda-11.7/include:/usr/local/cuda-11.7/extras/CUPTI/include
                    FPATH=...
                FTP_PROXY=<set>
                   GOPATH=/home/linuxbrew/.linuxbrew/opt/go
              HTTPS_PROXY=<set>
               HTTP_PROXY=<set>
                 INFOPATH=/home/linuxbrew/.linuxbrew/share/info:/home/linuxbrew/.linuxbrew/share
                          /info:
          LD_LIBRARY_PATH=/usr/local/cuda-11.7/lib64:/usr/local/cuda-11.7/extras/CUPTI/lib64:/ho
                          me/PanXuehai/.local/lib
               LD_PRELOAD=<not set>
             LIBRARY_PATH=/usr/local/cuda-11.7/lib64:/usr/local/cuda-11.7/extras/CUPTI/lib64:/ho
                          me/PanXuehai/.local/lib
                  MANPATH=/home/linuxbrew/.linuxbrew/share/man:/home/linuxbrew/.linuxbrew/share/
                          man:::
                     PATH=...
       REQUESTS_CA_BUNDLE=<not set>
            SSL_CERT_FILE=<not set>
                all_proxy=<set>
                ftp_proxy=<set>
               http_proxy=<set>
              https_proxy=<set>

     active environment : None
            shell level : 0
       user config file : /home/PanXuehai/.condarc
 populated config files : /home/PanXuehai/.condarc
          conda version : 22.11.1
    conda-build version : 3.22.0
         python version : 3.9.15.final.0
       virtual packages : __archspec=1=x86_64
                          __glibc=2.31=0
                          __linux=5.15.79.1=0
                          __unix=0=0
       base environment : /home/PanXuehai/Miniconda3  (writable)
      conda av data dir : /home/PanXuehai/Miniconda3/etc/conda
  conda av metadata url : None
           channel URLs : https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/linux-64
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/noarch
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/noarch
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r/linux-64
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r/noarch
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2/linux-64
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2/noarch
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/linux-64
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/noarch
          package cache : /home/PanXuehai/Miniconda3/pkgs
                          /home/PanXuehai/.conda/pkgs
       envs directories : /home/PanXuehai/Miniconda3/envs
                          /home/PanXuehai/.conda/envs
               platform : linux-64
             user-agent : conda/22.11.1 requests/2.28.1 CPython/3.9.15 Linux/5.15.79.1-microsoft-standard-WSL2 ubuntu/20.04.3 glibc/2.31
                UID:GID : 1000:1000
             netrc file : None
           offline mode : False


An unexpected error has occurred. Conda has prepared the above report.
```

</details>

`conda` works fine with the same arguments:

<details>
<summary>Output of `conda create -n test pytorch::pytorch -y`</summary>

```text
Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

environment location: /home/PanXuehai/Miniconda3/envs/test

added / updated specs:
- pytorch::pytorch


The following NEW packages will be INSTALLED:

_libgcc_mutex      anaconda/pkgs/main/linux-64::_libgcc_mutex-0.1-main
_openmp_mutex      anaconda/pkgs/main/linux-64::_openmp_mutex-5.1-1_gnu
blas               anaconda/pkgs/main/linux-64::blas-1.0-mkl
bzip2              anaconda/pkgs/main/linux-64::bzip2-1.0.8-h7b6447c_0
ca-certificates    anaconda/pkgs/main/linux-64::ca-certificates-2022.10.11-h06a4308_0
certifi            anaconda/pkgs/main/linux-64::certifi-2022.12.7-py310h06a4308_0
flit-core          anaconda/pkgs/main/noarch::flit-core-3.6.0-pyhd3eb1b0_0
intel-openmp       anaconda/pkgs/main/linux-64::intel-openmp-2022.1.0-h9e868ea_3769
ld_impl_linux-64   anaconda/pkgs/main/linux-64::ld_impl_linux-64-2.38-h1181459_1
libffi             anaconda/pkgs/main/linux-64::libffi-3.4.2-h6a678d5_6
libgcc-ng          anaconda/pkgs/main/linux-64::libgcc-ng-11.2.0-h1234567_1
libgomp            anaconda/pkgs/main/linux-64::libgomp-11.2.0-h1234567_1
libstdcxx-ng       anaconda/pkgs/main/linux-64::libstdcxx-ng-11.2.0-h1234567_1
libuuid            anaconda/pkgs/main/linux-64::libuuid-1.41.5-h5eee18b_0
mkl                anaconda/pkgs/main/linux-64::mkl-2022.1.0-hc2b9512_224
ncurses            anaconda/pkgs/main/linux-64::ncurses-6.3-h5eee18b_3
openssl            anaconda/pkgs/main/linux-64::openssl-1.1.1s-h7f8727e_0
pip                anaconda/pkgs/main/linux-64::pip-22.3.1-py310h06a4308_0
python             anaconda/pkgs/main/linux-64::python-3.10.8-h7a1cb2a_1
pytorch            pytorch/linux-64::pytorch-1.13.1-py3.10_cpu_0
pytorch-mutex      pytorch/noarch::pytorch-mutex-1.0-cpu
readline           anaconda/pkgs/main/linux-64::readline-8.2-h5eee18b_0
setuptools         anaconda/pkgs/main/linux-64::setuptools-65.5.0-py310h06a4308_0
sqlite             anaconda/pkgs/main/linux-64::sqlite-3.40.0-h5082296_0
tk                 anaconda/pkgs/main/linux-64::tk-8.6.12-h1ccaba5_0
typing_extensions  anaconda/pkgs/main/linux-64::typing_extensions-4.4.0-py310h06a4308_0
tzdata             anaconda/pkgs/main/noarch::tzdata-2022g-h04d1e81_0
wheel              anaconda/pkgs/main/noarch::wheel-0.37.1-pyhd3eb1b0_0
xz                 anaconda/pkgs/main/linux-64::xz-5.2.8-h5eee18b_0
zlib               anaconda/pkgs/main/linux-64::zlib-1.2.13-h5eee18b_0



Downloading and Extracting Packages

Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
#     $ conda activate test
#
# To deactivate an active environment, use
#
#     $ conda deactivate

```

</details>

In `conda/core/solve.py`, it does an extra check when `force_reinstall` is true:

https://github.com/conda/conda/blob/f474462658ef6e3763c1193db0f8edbea01fa5fe/conda/core/solve.py#L1163-L1169

```python
    # If force_reinstall is enabled, make sure any package in specs_to_add is unlinked then
    # re-linked
    if force_reinstall:
        for spec in specs_to_add:
            prec = next((rec for rec in final_precs if spec.match(rec)), None)
            assert prec
            _add_to_unlink_and_link(prec)
```

The program fails at `assert prec`.

After removing some irrelevant content, the value of `specs_to_add` and `final_precs` are different solved by `conda` (green) and `mamba` (red):

```diff
-specs_to_add: [MatchSpec("pytorch::pytorch")]
+specs_to_add: frozenset({MatchSpec("pytorch::pytorch")})
 final_precs: IndexedSet([
     PackageRecord(name='pytorch-mutex',
         version='1.0',
         build='cpu',
         build_number=0,
-        channel=Channel("anaconda/cloud/pytorch/noarch"),
+        channel=Channel("pytorch/noarch"),
         subdir='noarch',
         fn='pytorch-mutex-1.0-cpu.tar.bz2',
         md5='49565ed726991fd28d08a39885caa88d',
         url='https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/noarch/pytorch-mutex-1.0-cpu.tar.bz2',
         sha256='d48c964188ca49660d750cffd73698d217cf94e694cd51987f9f186425435e76',
+        arch=None,
+        platform=None,
         depends=(),
-        constrains=(),
         track_features=('pytorch-mutex',),
-        license='',
+        noarch='generic',
         size=2897
     ),
     PackageRecord(name='pytorch',
         version='1.13.1',
         build='py3.10_cpu_0',
         build_number=0,
-        channel=Channel("anaconda/cloud/pytorch/linux-64"),
+        channel=Channel("pytorch/linux-64"),
         subdir='linux-64',
         fn='pytorch-1.13.1-py3.10_cpu_0.tar.bz2',
         md5='61a620aec1253656c1e8eaaf5e842f0f',
         url='https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/linux-64/pytorch-1.13.1-py3.10_cpu_0.tar.bz2',
         sha256='7e78247a77c24409553ec11dff114049019631d6f25c4bc9f6a41c983cb80275',
+        arch=None,
+        platform=None,
         depends=(
             'blas * mkl',
             'mkl >=2018',
             'python >=3.10,<3.11.0a0',
             'pytorch-mutex 1.0 cpu',
             'typing_extensions'
         ),
         constrains=('cpuonly',),
-        track_features=(),
         license='BSD 3-Clause',
+        license_family='BSD',
         size=85592222
     ),
     ...
 ])
```

`mamba` solves the channel as `Channel("anaconda/cloud/pytorch/noarch")` while `conda` outputs `Channel("pytorch/noarch")`.

### mamba info / micromamba info

```shell
                  __    __    __    __
                 /  \  /  \  /  \  /  \
                /    \/    \/    \/    \
███████████████/  /██/  /██/  /██/  /████████████████████████
              /  / \   / \   / \   / \  \____
             /  /   \_/   \_/   \_/   \    o \__,
            / _/                       \_____/  `
            |/
        ███╗   ███╗ █████╗ ███╗   ███╗██████╗  █████╗
        ████╗ ████║██╔══██╗████╗ ████║██╔══██╗██╔══██╗
        ██╔████╔██║███████║██╔████╔██║██████╔╝███████║
        ██║╚██╔╝██║██╔══██║██║╚██╔╝██║██╔══██╗██╔══██║
        ██║ ╚═╝ ██║██║  ██║██║ ╚═╝ ██║██████╔╝██║  ██║
        ╚═╝     ╚═╝╚═╝  ╚═╝╚═╝     ╚═╝╚═════╝ ╚═╝  ╚═╝

        mamba (1.1.0) supported by @QuantStack

        GitHub:  https://github.com/mamba-org/mamba
        Twitter: https://twitter.com/QuantStack

█████████████████████████████████████████████████████████████


     active environment : None
            shell level : 0
       user config file : /home/PanXuehai/.condarc
 populated config files : /home/PanXuehai/.condarc
          conda version : 22.11.1
    conda-build version : not installed
         python version : 3.9.15.final.0
       virtual packages : __archspec=1=x86_64
                          __cuda=12.0=0
                          __glibc=2.31=0
                          __linux=5.15.0=0
                          __unix=0=0
       base environment : /home/PanXuehai/Miniconda3  (writable)
      conda av data dir : /home/PanXuehai/Miniconda3/etc/conda
  conda av metadata url : None
           channel URLs : https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/linux-64
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/noarch
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/noarch
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r/linux-64
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r/noarch
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2/linux-64
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2/noarch
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/linux-64
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/noarch
          package cache : /home/PanXuehai/Miniconda3/pkgs
                          /home/PanXuehai/.conda/pkgs
       envs directories : /home/PanXuehai/Miniconda3/envs
                          /home/PanXuehai/.conda/envs
               platform : linux-64
             user-agent : conda/22.11.1 requests/2.28.1 CPython/3.9.15 Linux/5.15.0-56-generic ubuntu/20.04.5 glibc/2.31
                UID:GID : 1000:1000
             netrc file : /home/PanXuehai/.netrc
           offline mode : False
```


### Logs

```shell
# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<

    Traceback (most recent call last):
      File "/home/PanXuehai/Miniconda3/lib/python3.9/site-packages/conda/exceptions.py", line 1118, in __call__
        return func(*args, **kwargs)
      File "/home/PanXuehai/Miniconda3/lib/python3.9/site-packages/mamba/mamba.py", line 936, in exception_converter
        raise e
      File "/home/PanXuehai/Miniconda3/lib/python3.9/site-packages/mamba/mamba.py", line 929, in exception_converter
        exit_code = _wrapped_main(*args, **kwargs)
      File "/home/PanXuehai/Miniconda3/lib/python3.9/site-packages/mamba/mamba.py", line 887, in _wrapped_main
        result = do_call(parsed_args, p)
      File "/home/PanXuehai/Miniconda3/lib/python3.9/site-packages/mamba/mamba.py", line 754, in do_call
        exit_code = create(args, parser)
      File "/home/PanXuehai/Miniconda3/lib/python3.9/site-packages/mamba/mamba.py", line 630, in create
        return install(args, parser, "create")
      File "/home/PanXuehai/Miniconda3/lib/python3.9/site-packages/mamba/mamba.py", line 588, in install
        conda_transaction = to_txn(
      File "/home/PanXuehai/Miniconda3/lib/python3.9/site-packages/mamba/utils.py", line 443, in to_txn
        return to_txn_precs(
      File "/home/PanXuehai/Miniconda3/lib/python3.9/site-packages/mamba/utils.py", line 406, in to_txn_precs
        unlink_precs, link_precs = diff_for_unlink_link_precs(
      File "/home/PanXuehai/Miniconda3/lib/python3.9/site-packages/conda/core/solve.py", line 1172, in diff_for_unlink_link_precs
        assert prec
    AssertionError

`$ /home/PanXuehai/Miniconda3/bin/mamba create -n test pytorch::pytorch -y`

  environment variables:
                ALL_PROXY=<set>
                 CIO_TEST=<not set>
                CONDA_EXE=/home/PanXuehai/Miniconda3/bin/conda
   CONDA_PYTHONBREAKPOINT=
         CONDA_PYTHON_EXE=/home/PanXuehai/Miniconda3/bin/python
               CONDA_ROOT=/home/PanXuehai/Miniconda3
              CONDA_SHLVL=0
       CPLUS_INCLUDE_PATH=/usr/local/cuda-11.7/include:/usr/local/cuda-11.7/extras/CUPTI/include
           CURL_CA_BUNDLE=<not set>
           C_INCLUDE_PATH=/usr/local/cuda-11.7/include:/usr/local/cuda-11.7/extras/CUPTI/include
                    FPATH=...
                FTP_PROXY=<set>
                   GOPATH=/home/linuxbrew/.linuxbrew/opt/go
              HTTPS_PROXY=<set>
               HTTP_PROXY=<set>
                 INFOPATH=/home/linuxbrew/.linuxbrew/share/info:/home/linuxbrew/.linuxbrew/share
                          /info:
          LD_LIBRARY_PATH=/usr/local/cuda-11.7/lib64:/usr/local/cuda-11.7/extras/CUPTI/lib64:/ho
                          me/PanXuehai/.local/lib
               LD_PRELOAD=<not set>
             LIBRARY_PATH=/usr/local/cuda-11.7/lib64:/usr/local/cuda-11.7/extras/CUPTI/lib64:/ho
                          me/PanXuehai/.local/lib
                  MANPATH=/home/linuxbrew/.linuxbrew/share/man:/home/linuxbrew/.linuxbrew/share/
                          man:::
                     PATH=...
       REQUESTS_CA_BUNDLE=<not set>
            SSL_CERT_FILE=<not set>
                all_proxy=<set>
                ftp_proxy=<set>
               http_proxy=<set>
              https_proxy=<set>

     active environment : None
            shell level : 0
       user config file : /home/PanXuehai/.condarc
 populated config files : /home/PanXuehai/.condarc
          conda version : 22.11.1
    conda-build version : 3.22.0
         python version : 3.9.15.final.0
       virtual packages : __archspec=1=x86_64
                          __glibc=2.31=0
                          __linux=5.15.79.1=0
                          __unix=0=0
       base environment : /home/PanXuehai/Miniconda3  (writable)
      conda av data dir : /home/PanXuehai/Miniconda3/etc/conda
  conda av metadata url : None
           channel URLs : https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/linux-64
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/noarch
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/noarch
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r/linux-64
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r/noarch
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2/linux-64
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2/noarch
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/linux-64
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/noarch
          package cache : /home/PanXuehai/Miniconda3/pkgs
                          /home/PanXuehai/.conda/pkgs
       envs directories : /home/PanXuehai/Miniconda3/envs
                          /home/PanXuehai/.conda/envs
               platform : linux-64
             user-agent : conda/22.11.1 requests/2.28.1 CPython/3.9.15 Linux/5.15.79.1-microsoft-standard-WSL2 ubuntu/20.04.3 glibc/2.31
                UID:GID : 1000:1000
             netrc file : None
           offline mode : False


An unexpected error has occurred. Conda has prepared the above report.
```


### environment.yml

_No response_

### ~/.condarc

```yaml
channels:
  - pytorch
  - defaults
  - conda-forge
default_channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
  conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
channel_priority: flexible

ssl_verify: true
show_channel_urls: false
report_errors: false

force_reinstall: true
```



Discussion: Great report, thanks!



Fix (patch):
diff --git a/libmamba/src/core/channel.cpp b/libmamba/src/core/channel.cpp
index 3b87300588..fdfe7772ab 100644
--- a/libmamba/src/core/channel.cpp
+++ b/libmamba/src/core/channel.cpp
@@ -844,8 +844,7 @@ namespace mamba
             if (!starts_with(url, "http"))
                 url = path_to_url(url);
 
-            auto channel
-                = ChannelBuilder::make_simple_channel(m_channel_alias, join_url(url, n), "", n);
+            auto channel = ChannelBuilder::make_simple_channel(m_channel_alias, url, n, "");
             m_custom_channels.emplace(n, std::move(channel));
         }