azure-cli icon indicating copy to clipboard operation
azure-cli copied to clipboard

Python get_path error after updating to 2.60.0

Open davidbgonz opened this issue 1 year ago • 1 comments

Describe the bug

Any az commands result in a python error.

Related command

Any az command including just running az and az --help

Errors

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/opt/azure-cli/lib/python3.12/site-packages/azure/cli/__main__.py", line 39, in <module>
    az_cli = get_default_cli()
             ^^^^^^^^^^^^^^^^^
  File "/opt/azure-cli/lib/python3.12/site-packages/azure/cli/core/__init__.py", line 917, in get_default_cli
    from azure.cli.core.azlogging import AzCliLogging
  File "/opt/azure-cli/lib/python3.12/site-packages/azure/cli/core/azlogging.py", line 30, in <module>
    from azure.cli.core.commands.events import EVENT_INVOKER_PRE_CMD_TBL_TRUNCATE
  File "/opt/azure-cli/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 25, in <module>
    from azure.cli.core.extension import get_extension
  File "/opt/azure-cli/lib/python3.12/site-packages/azure/cli/core/extension/__init__.py", line 25, in <module>
    EXTENSIONS_SYS_DIR = os.path.expanduser(_CUSTOM_EXT_SYS_DIR) if _CUSTOM_EXT_SYS_DIR else os.path.join(get_path("purepath"), 'azure-cli-extensions')
                                                                                                          ^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/sysconfig.py", line 636, in get_path
    return get_paths(scheme, vars, expand)[name]
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
KeyError: 'purepath'

Issue script & Debug output

Any command with the --debug flag still results in the above error.

Expected behavior

Since any command errors out, expected behavior is to at least make it passed that python error.

Environment Summary

Running az --version still results in the same error. I can use 2.59.0 and update the azure-cli and core versions manually below:

azure-cli                         2.60.0

core                              2.60.0
telemetry                          1.1.0

Extensions:
azure-devops                      0.26.0
ssh                                1.1.6

Dependencies:
msal                              1.28.0
azure-mgmt-resource             23.1.0b2

Python location '/opt/azure-cli/bin/python'
Extensions directory '/home/<user>/.azure/cliextensions'

Python (Linux) 3.12.3 (main, Apr 23 2024, 09:16:07) [GCC 13.2.1 20240417]

Additional context

Pathlib was updated recently and have been experiencing other tools such as neovim extensions needing updates to reflect the new changes. This cloud be related to that, although 2.59.0 is still functional when I rollback to that version.

davidbgonz avatar May 02 '24 15:05 davidbgonz

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

yonzhan avatar May 02 '24 15:05 yonzhan

Which OS are you using? The path indicates that it's not an official CLI package.

bebound avatar May 06 '24 03:05 bebound

I can confirm this issue on arch linux with azure-cli package from the official extra repo and version azure-cli-2.60.0-1. Meanwhile it has been fixed in azure-cli-2.60.0-3. Not sure what has changed, but the commit message mentions that the build process was broken. https://gitlab.archlinux.org/archlinux/packaging/packages/azure-cli/-/commit/451bdff2373a99d6c77336b642a7fb01eba6f2a8

@davidbgonz if you are on arch too, try to update the azure-cli package again.

superkartoffel avatar May 06 '24 07:05 superkartoffel

Arch's extra/azure-cli 2.60.0-1 package is broken and fixed in newer version. Mentioned in https://github.com/Azure/azure-cli/pull/28796#issuecomment-2086891170

bebound avatar May 06 '24 07:05 bebound

I'm on arch. Yep, can confirm that the issue with that 2.60.0-1 build is now fixed in 2.60.0-3. Should this issue stay open until that PR is complete?

davidbgonz avatar May 06 '24 15:05 davidbgonz

Close as Arch package is fixed. The root issue is Python 3.12 support, which is tracked in #27673

bebound avatar May 07 '24 03:05 bebound