Skip to content

fix(import): dedup imported channels by resolved base url - #6604

Open
pinin4fjords wants to merge 2 commits into
prefix-dev:mainfrom
pinin4fjords:fix/dedup-imported-channels-by-base-url
Open

fix(import): dedup imported channels by resolved base url#6604
pinin4fjords wants to merge 2 commits into
prefix-dev:mainfrom
pinin4fjords:fix/dedup-imported-channels-by-base-url

Conversation

@pinin4fjords

Copy link
Copy Markdown

Summary

Fixes #6603.

pixi init --import kept a channel twice when it was declared by name in channels: and also referenced via an explicit channel::package prefix in dependencies: — a very common pattern in conda/bioconda environment.yml files (e.g. bioconda::bismark=3.1.0 alongside channels: [conda-forge, bioconda]).

In CondaEnvFile::to_manifest, parse_dependencies resolves a picked-up channel to its full url (channel.base_url.as_str()), while parse_channels leaves channels from the channels: block as their original short name. These two representations of the same channel don't compare equal, so Itertools::unique() couldn't merge them and both survived into the final channel list (and from there into every generated pixi.lock).

This switches the dedup to compare by resolved base url (via NamedChannelOrUrl::into_base_url) rather than by literal NamedChannelOrUrl value, so a channel referenced two different ways is only kept once.

Changes

  • CondaEnvFile::to_manifest: dedup channels with unique_by keyed on the resolved base url instead of unique().
  • Updated test_parse_conda_env_file, whose expected output previously baked in the duplicate conda-forge entry produced by this bug.
  • Added test_import_dedups_channel_declared_by_name_and_referenced_by_dependency_prefix, a regression test using the exact channels:/dependencies: shape from the bug report.

Test plan

  • cargo test -p pixi_utils --lib conda_environment_file — 5/5 passing, including the new regression test
  • cargo fmt -p pixi_utils -- --check — clean
  • cargo clippy -p pixi_utils --lib -- -D warnings — clean
  • Manually reproduced the original bug against the bismark environment.yml from the linked issue with pixi init --import (pixi 0.72.2) before applying this fix, confirmed the fix removes the duplicate

`pixi init --import` kept a channel twice when it was declared by name
in `channels:` and also referenced via an explicit `channel::package`
prefix in `dependencies:` (a very common pattern in conda/bioconda
environment.yml files). The dependency-picked-up channel is resolved
to its full url before being added to the channel list, so it never
compared equal to the same channel's short name entry and survived
`Itertools::unique()` as a spurious duplicate.

Dedup by the channel's resolved base url instead of by literal
`NamedChannelOrUrl` value.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(init): --import duplicates a channel when a dependency uses channel::pkg and the channel is already in channels:

1 participant