Skip to content

Conversation

@prady0t
Copy link
Contributor

@prady0t prady0t commented Nov 27, 2025

Description

Fixes #4594

How Has This Been Tested?

Building locally and running pixi add --channel [channel_name] [package] now works and the manifest files are updated accordingly. Test it out with pixi add --channel bioconda samtools

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added sufficient tests to cover my changes.
  • I have verified that changes that would impact the JSON schema have been made in schema/model.py.

@baszalmstra
Copy link
Contributor

Thanks for the contribution. Could you take a look at the CI issues? Can you also add tests? Especially around what happens if the channel is already present?

There is also syntax for matchspec, which looks like bioconda::samtools. Might actually make sense to support that?

@prady0t
Copy link
Contributor Author

prady0t commented Nov 29, 2025

There is also syntax for matchspec, which looks like bioconda::samtools. Might actually make sense to support that?

I'm quite new to pixi 😅 could you elaborate on this a bit more?

@prady0t
Copy link
Contributor Author

prady0t commented Dec 3, 2025

@baszalmstra I've tried adding support of MatchSpec's channel syntax. Users can now do pixi add conda-forge::pytorch=2.2 , and it will add conda-forge to the list of channels. I'll be adding some tests to verify this.

@baszalmstra
Copy link
Contributor

Something seems to have broken in the tests. Can you take a look?

I will hold off with merging this until @ruben-arts gets back. I want his approval with regard to the UX.


// Add a channel
let channel = args.channel;
workspace.manifest().add_channels([PrioritizedChannel::from(NamedChannelOrUrl::Name(String::from(channel.unwrap_or_default()))).clone()], &FeatureName::DEFAULT, false)?;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line just calls the add_channels() function with the args given from the user, so testing this is essentially testing the functionalities of add_channel() which is already tested and also includes the situation where we try to add channel when it's already present.

@baszalmstra Do you think we sould still try to add tests for this? If so could me point to where the tests for cli inputs are(or should be) present.

Comment on lines -1407 to -1474
# successful after adding the channel
verify_cli_command(
[
pixi,
"add",
"https://repo.prefix.dev/bioconda::snakemake-minimal",
"--manifest-path",
tmp_pixi_workspace,
],
stderr_contains="Added https://repo.prefix.dev/bioconda::snakemake-minimal",
)

# no message for initially unused feature...
verify_cli_command(
[
pixi,
"add",
"https://conda.anaconda.org/conda-forge::xz",
"--feature=prefix",
"--manifest-path",
tmp_pixi_workspace,
],
)
verify_cli_command(
[
pixi,
"workspace",
"environment",
"add",
"prefix",
"--feature=prefix",
"--manifest-path",
tmp_pixi_workspace,
],
)
# ...but decent message on install:
verify_cli_command(
[
pixi,
"install",
"--environment=prefix",
"--manifest-path",
tmp_pixi_workspace,
],
expected_exit_code=ExitCode.FAILURE,
stderr_contains="unavailable channel 'https://conda.anaconda.org/conda-forge/'",
)
# and helpful message now feature is used:
verify_cli_command(
[
pixi,
"add",
"https://conda.anaconda.org/conda-forge::libzlib",
"--feature=prefix",
"--manifest-path",
tmp_pixi_workspace,
],
expected_exit_code=ExitCode.FAILURE,
stderr_contains="pixi workspace channel add https://conda.anaconda.org/conda-forge",
)

verify_cli_command(
[
pixi,
"workspace",
"channel",
"add",
"--feature=prefix",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed these as using matchspec syntax adds the channel if not found, hence these tests are irrelevant.

spec_type: SpecType,
dep_options: DependencyOptions,
git_options: GitOptions,
channel: Option<Vec<NamedChannelOrUrl>>,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

channel is now Option<Vec> as oppose to Option earlier. This helps us take url and local channel paths as part of matchspec as well.

@prady0t
Copy link
Contributor Author

prady0t commented Dec 7, 2025

The tests are now passing, and I've added some tests to check for --channel arg as well as channel in matchspec.

Comment on lines -1399 to -1468
"workspace",
"channel",
"add",
"https://repo.prefix.dev/bioconda",
"--manifest-path",
tmp_pixi_workspace,
],
)
# successful after adding the channel
verify_cli_command(
[
pixi,
"add",
"https://repo.prefix.dev/bioconda::snakemake-minimal",
"--manifest-path",
tmp_pixi_workspace,
],
stderr_contains="Added https://repo.prefix.dev/bioconda::snakemake-minimal",
)

# no message for initially unused feature...
verify_cli_command(
[
pixi,
"add",
"https://conda.anaconda.org/conda-forge::xz",
"--feature=prefix",
"--manifest-path",
tmp_pixi_workspace,
],
)
verify_cli_command(
[
pixi,
"workspace",
"environment",
"add",
"prefix",
"--feature=prefix",
"--manifest-path",
tmp_pixi_workspace,
],
)
# ...but decent message on install:
verify_cli_command(
[
pixi,
"install",
"--environment=prefix",
"--manifest-path",
tmp_pixi_workspace,
],
expected_exit_code=ExitCode.FAILURE,
stderr_contains="unavailable channel 'https://conda.anaconda.org/conda-forge/'",
)
# and helpful message now feature is used:
verify_cli_command(
[
pixi,
"add",
"https://conda.anaconda.org/conda-forge::libzlib",
"--feature=prefix",
"--manifest-path",
tmp_pixi_workspace,
],
expected_exit_code=ExitCode.FAILURE,
stderr_contains="pixi workspace channel add https://conda.anaconda.org/conda-forge",
)

verify_cli_command(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove these tests?

@ruben-arts
Copy link
Contributor

My question is whether we should force the dependencies you specify when calling them with --channel if they should come from that channel. e.g. now it produces this:

pixi add --channel bioconda snakemake samtools
[workspace]
channels = ["conda-forge", "bioconda"]
platforms = ["osx-arm64"]

[dependencies]
snakemake = ">=9.14.3,<10"
samtools = ">=1.22.1,<2"

But

pixi add bioconda::snakemake bioconda::samtools

Creates:

[workspace]
channels = ["conda-forge", "https://conda.anaconda.org/bioconda"] # I would say this conda.anaconda.org part can be seen as a bug...
platforms = ["osx-arm64"]

[dependencies]
snakemake = { version = ">=9.14.3,<10", channel = "bioconda" } # Specifically this channel
samtools = { version = ">=1.22.1,<2", channel = "bioconda" } # Specifically this channel

Should these two-way's of defining create the same TOML? I think yes.

@baszalmstra
Copy link
Contributor

I agree. @prady0t You can use the ChannelConfig to convert urls back to names.

@prady0t
Copy link
Contributor Author

prady0t commented Dec 10, 2025

Thanks for the review, this is a bug indeed. Working on it now.

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.

feat(add): --channel parameter

3 participants