#16690·conda

`conda config --remove` drops `#!top` and `#!bottom` from remaining channels

Author: jezdezCreated Sep 16, 2026Updated Sep 18, 2026
Labelstype::bug

Checklist

  • I added a descriptive title
  • I searched open reports and couldn't find a duplicate

What happened?

Removing one channel with conda config --remove also removes the #!top and #!bottom directives attached to the remaining channels. The command succeeds without a warning. These directives affect configuration merging, so this can change channel ordering beyond the requested edit.

Create a temporary configuration file with these contents:

yaml
channels:
  - alpha  #!top
  - beta
  - gamma  #!bottom

Run:

bash
conda config --file <temporary-config> --remove channels beta

The command exits successfully and writes:

yaml
channels:
  - alpha
  - gamma

Expected:

yaml
channels:
  - alpha  #!top
  - gamma  #!bottom

Comments and directives attached to surviving entries should remain.

Conda Info

Reproduced through the CLI with conda 26.5.0.

Conda Config

The complete synthetic configuration is shown above. The reproduction uses an explicit temporary file and disables external plugins.

Conda list

No package installation or solver operation is involved.

Additional Context

Current main at 4b1f1fe1aec1511d87548125ff25076e60202fd2 retains the same sequence replacement in ConfigurationFile.remove_item(). It replaces the loaded sequence with a plain list comprehension, discarding comments attached to the surviving entries. The duplicate-item path in add() also rebuilds the sequence this way.

Related to #10278, which concerns --remove-key deleting a following commented-out section, and the configuration tracking issue #12355.