这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@soapy1
Copy link
Contributor

@soapy1 soapy1 commented Aug 4, 2025

Description

With this change, conda will not allow users to specify extra packages using the --file arg when cloning an environment. This makes the conda create --clone command more consistent in the arguments that are allowed.

$ conda create  --clone existing -n testenv2 python                                                                                                                               

TooManyArgumentsError: did not expect any arguments for --clone Got 1 argument (python) but expected 0.

$ conda create  --clone existing -n testenv2 --file tests/env/support/requirements.txt                                                                                         

TooManyArgumentsError: --file and --clone arguments are mutually exclusive Got 1 argument (tests/env/support/requirements.txt) but expected 0.

fixes #15072

Checklist - did you ...

  • Add a file to the news directory (using the template) for the next release's release notes?
  • Add / update necessary tests?
  • Add / update outdated documentation?

@github-project-automation github-project-automation bot moved this to 🆕 New in 🔎 Review Aug 4, 2025
@conda-bot conda-bot added the cla-signed [bot] added once the contributor has signed the CLA label Aug 4, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Aug 4, 2025

CodSpeed Instrumentation Performance Report

Merging #15073 will not alter performance

Comparing soapy1:cant-clone-and-file (c3e5830) with main (a9b6ff5)

Summary

✅ 21 untouched benchmarks

@soapy1 soapy1 force-pushed the cant-clone-and-file branch from 3af25d6 to 44e11cb Compare August 5, 2025 04:53
@soapy1 soapy1 marked this pull request as ready for review August 5, 2025 05:18
@soapy1 soapy1 requested a review from a team as a code owner August 5, 2025 05:18
Copy link
Contributor

@ryanskeith ryanskeith left a comment

Choose a reason for hiding this comment

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

Looks good. I do have a suggestion on a better error message.

@soapy1 soapy1 force-pushed the cant-clone-and-file branch from 44e11cb to 82df68a Compare August 5, 2025 20:56
Copy link
Member

@jezdez jezdez left a comment

Choose a reason for hiding this comment

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

Minor fixes, so the exception is rendered consistently.

@github-project-automation github-project-automation bot moved this from 🆕 New to 🏗️ In Progress in 🔎 Review Aug 6, 2025
@jezdez
Copy link
Member

jezdez commented Aug 6, 2025

To be clear, based on how the exception message is built:

conda/conda/exceptions.py

Lines 145 to 167 in a9b6ff5

class TooManyArgumentsError(ArgumentError):
def __init__(
self,
expected: int,
received: int,
offending_arguments: Iterable[str],
optional_message: str = "",
*args,
):
self.expected = expected
self.received = received
self.offending_arguments = offending_arguments
self.optional_message = optional_message
suffix = "s" if received - expected > 1 else ""
msg = "{} Got {} argument{} ({}) but expected {}.".format(
optional_message,
received,
suffix,
", ".join(offending_arguments),
expected,
)
super().__init__(msg, *args)

Co-authored-by: Jannis Leidel <jannis@leidel.info>
@github-project-automation github-project-automation bot moved this from 🏗️ In Progress to ✅ Approved in 🔎 Review Aug 7, 2025
@jezdez jezdez merged commit eb19a56 into conda:main Aug 7, 2025
75 checks passed
@github-project-automation github-project-automation bot moved this from ✅ Approved to 🏁 Done in 🔎 Review Aug 7, 2025
@kenodegard kenodegard mentioned this pull request Sep 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed [bot] added once the contributor has signed the CLA

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

conda create --clone argument is ignored if a --file is provided

4 participants