fix(import): dedup imported channels by resolved base url - #6604
Open
pinin4fjords wants to merge 2 commits into
Open
fix(import): dedup imported channels by resolved base url#6604pinin4fjords wants to merge 2 commits into
pinin4fjords wants to merge 2 commits into
Conversation
`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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #6603.
pixi init --importkept a channel twice when it was declared by name inchannels:and also referenced via an explicitchannel::packageprefix independencies:— a very common pattern in conda/biocondaenvironment.ymlfiles (e.g.bioconda::bismark=3.1.0alongsidechannels: [conda-forge, bioconda]).In
CondaEnvFile::to_manifest,parse_dependenciesresolves a picked-up channel to its full url (channel.base_url.as_str()), whileparse_channelsleaves channels from thechannels:block as their original short name. These two representations of the same channel don't compare equal, soItertools::unique()couldn't merge them and both survived into the final channel list (and from there into every generatedpixi.lock).This switches the dedup to compare by resolved base url (via
NamedChannelOrUrl::into_base_url) rather than by literalNamedChannelOrUrlvalue, so a channel referenced two different ways is only kept once.Changes
CondaEnvFile::to_manifest: dedup channels withunique_bykeyed on the resolved base url instead ofunique().test_parse_conda_env_file, whose expected output previously baked in the duplicateconda-forgeentry produced by this bug.test_import_dedups_channel_declared_by_name_and_referenced_by_dependency_prefix, a regression test using the exactchannels:/dependencies:shape from the bug report.Test plan
cargo test -p pixi_utils --lib conda_environment_file— 5/5 passing, including the new regression testcargo fmt -p pixi_utils -- --check— cleancargo clippy -p pixi_utils --lib -- -D warnings— cleanenvironment.ymlfrom the linked issue withpixi init --import(pixi 0.72.2) before applying this fix, confirmed the fix removes the duplicate