`conda config --remove` drops `#!top` and `#!bottom` from remaining channels
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:
channels:
- alpha #!top
- beta
- gamma #!bottomRun:
conda config --file <temporary-config> --remove channels betaThe command exits successfully and writes:
channels:
- alpha
- gammaExpected:
channels:
- alpha #!top
- gamma #!bottomComments 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.
Source: conda/conda