Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] path argument no longer position independent for "conan lock create" in Conan 2.1.0 #3629

Open
antoinebardoz opened this issue Feb 16, 2024 · 2 comments
Assignees

Comments

@antoinebardoz
Copy link

Environment details

  • Operating System+version: Ubuntu 22.04
  • Compiler+version: N/A
  • Conan version: 2.1.0
  • Python version: 3.10.8

Steps to reproduce

  1. conan lock create -r myremote -u path/to/conanfile
  2. Conan returns: ERROR: Please specify a path to a conanfile or a '--requires=<ref>'

This doesn't happen if I don't have -u in the command. It also doesn't happen if I put the path first:
conan lock create path/to/conanfile -r myremote -u

This may apply to all commands. I saw it specifically with conan lock create, but after checking, I saw it happen with conan create as well.

Logs

No response

@RubenRBS RubenRBS self-assigned this Feb 16, 2024
@memsharded memsharded self-assigned this Feb 16, 2024
@memsharded
Copy link
Member

Hi @antoinebardoz

Thanks very much for your report.

I am afraid this is not a bug in Conan, but a limitation in Python argparse and how it handles arguments, something that we cannot fix.

It has affected this particular command in this case because of a small change in 2.1, but to illustrate the behavior this command:

conan create -v .

Failed both in 2.0 and 2.1.

The problem is argparse mostly prints the contextual help with conan create -h in an order that it is not able to process later for all scenarios, printing the mandatory positional arguments last in the short-usage format.
This fails when there are arguments with nargs="?" that can take 0 or more argument.

This is why in the Conan docs we always document and use the usage of positional arguments always first:

conan create . -v   # never fails

In your case, the correct command syntax as documented by Conan would be:

conan lock create path/to/conanfile -r=myremote -u

We tried in the past to fix the usage output in argparse to avoid this, but it was not easy. We are going to give it another try to avoid this confusion.

@memsharded
Copy link
Member

We have tried to improve the command --help output in https://github.com/conan-io/conan/pull/15761/files, to help with this. But overall it was not really helping much and it was a bit too hacky.
Also it happens this is a known Python bug: python/cpython#53584

So it seems this is out of our scope, I am moving this to the docs repo to add it to the docs, maybe an entry in the FAQ too. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants