Azure / azure-cli

Azure Command-Line Interface
MIT License
3.99k stars 2.96k forks source link

Unable to run azure cli 2.29.0, got "conflicting subparser" running every command #27025

Open easildur24 opened 1 year ago

easildur24 commented 1 year ago

Describe the bug

I have python 3.11 and installed azure-cli 2.29 using the command pip3 install azure-cli==2.29, everything ran successfully. However, I was not able to run any az commands, any command would give me the following error:

The command failed with an unexpected error. Here is the traceback: argument _subcommand: conflicting subparser: list Traceback (most recent call last): File "/opt/homebrew/lib/python3.11/site-packages/knack/cli.py", line 231, in invoke cmd_result = self.invocation.execute(args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/azure/cli/core/commands/init.py", line 560, in execute self.parser.load_command_table(self.commands_loader) File "/opt/homebrew/lib/python3.11/site-packages/azure/cli/core/parser.py", line 100, in load_command_table command_parser = subparser.add_parser(command_verb, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/python@3.11/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/argparse.py", line 1192, in addparser raise ArgumentError(self, ('conflicting subparser: %s') % name) argparse.ArgumentError: argument _subcommand: conflicting subparser: check-name

note that check-name could be other commands such as login, list etc.

I have tried cleaning up things and reinstall things, nothing works. Can someone help here?

Related command

brew install python3 pip3 install azure-cli==2.29 az login

The command failed with an unexpected error. Here is the traceback: argument _command_package: conflicting subparser: login Traceback (most recent call last): File "/opt/homebrew/lib/python3.11/site-packages/knack/cli.py", line 231, in invoke cmd_result = self.invocation.execute(args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/azure/cli/core/commands/init.py", line 560, in execute self.parser.load_command_table(self.commands_loader) File "/opt/homebrew/lib/python3.11/site-packages/azure/cli/core/parser.py", line 100, in load_command_table command_parser = subparser.add_parser(command_verb, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/python@3.11/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/argparse.py", line 1192, in addparser raise ArgumentError(self, ('conflicting subparser: %s') % name) argparse.ArgumentError: argument _command_package: conflicting subparser: login To open an issue, please run: 'az feedback'

Errors

The command failed with an unexpected error. Here is the traceback: argument _command_package: conflicting subparser: login Traceback (most recent call last): File "/opt/homebrew/lib/python3.11/site-packages/knack/cli.py", line 231, in invoke cmd_result = self.invocation.execute(args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/azure/cli/core/commands/init.py", line 560, in execute self.parser.load_command_table(self.commands_loader) File "/opt/homebrew/lib/python3.11/site-packages/azure/cli/core/parser.py", line 100, in load_command_table command_parser = subparser.add_parser(command_verb, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/python@3.11/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/argparse.py", line 1192, in addparser raise ArgumentError(self, ('conflicting subparser: %s') % name) argparse.ArgumentError: argument _command_package: conflicting subparser: login To open an issue, please run: 'az feedback'

Issue script & Debug output

no script

Expected behavior

The commands should run without issue

Environment Summary

azure-cli 2.29.0 *

core 2.29.0 telemetry 1.0.6

Python location '/opt/homebrew/opt/python@3.11/bin/python3.11' Extensions directory '/Users/lali/.azure/cliextensions'

Python (Darwin) 3.11.4 (main, Jul 25 2023, 17:36:13) [Clang 14.0.3 (clang-1403.0.22.14.1)]

Legal docs and information: aka.ms/AzureCliLegal

Additional context

No response

azure-client-tools-bot-prd[bot] commented 1 year ago

Hi @easildur24,

2.29.0 is not the latest Azure CLI(2.50.0).

Please upgrade to the latest Azure CLI version by following https://learn.microsoft.com/en-us/cli/azure/update-azure-cli.

yonzhan commented 1 year ago

Thank you for opening this issue, we will look into it.

easildur24 commented 1 year ago

Thanks, btw we have legacy terraform that requires us to run azure-cli 2.29 as any version later than that is not compatible.

bebound commented 1 year ago

The error is caused by python3.11 change, old code is not compatible with 3.11. You may install the azure-cli homebrew package.

easildur24 commented 1 year ago

I need azure-cli 2.29, what would be the resolution here?

I don't think I can install this version using homebrew anymore.

Would python 3.10 work?

easildur24 commented 1 year ago

I tried other python versions and ran into other issues. Is it still possible to install azure-cli 2.29 using homebrew?

bebound commented 1 year ago

You can try the homebrew 2.29, which bundles a python and should not affect by this.

easildur24 commented 1 year ago

What do you mean by homebrew 2.29? Here's what I ran:

% brew install azure-cli@2.29 ==> Downloading https://formulae.brew.sh/api/formula.jws.json

Warning: No available formula with the name "azure-cli@2.29". Did you mean azure-cli?

As I said, I think it's no longer supported.

easildur24 commented 1 year ago

I got it to work with python3.10 and azure 2.29, this is the only working combination without using homebrew.

SudeshnaBora commented 4 months ago

The issue persists with 2.61.0 of azure client and python 3.11. The only workaround is to use python 3.10 version.