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

Using default Python env fails when looking for config

Open dciborow opened this issue 1 year ago • 1 comments

Found an edge case when I went and skipped some of the setup steps, and did not create a dedicated Python env (particularly while creating a docker container that is already dedicated to the project).

pip install --upgrade pip
pip install azdev
azdev setup
Traceback (most recent call last):
  File "/home/codespace/.python/current/bin/azdev", line 8, in <module>
    sys.exit(main())
  File "/usr/local/python/3.10.4/lib/python3.10/site-packages/azdev/__main__.py", line 39, in main
    config_dir=get_azdev_config_dir())
  File "/usr/local/python/3.10.4/lib/python3.10/site-packages/azdev/utilities/config.py", line 24, in get_azdev_config_dir
    _, env_name = os.path.splitdrive(get_env_path())
  File "/usr/local/python/3.10.4/lib/python3.10/posixpath.py", line 134, in splitdrive
    p = os.fspath(p)
TypeError: expected str, bytes or os.PathLike object, not NoneType

https://github.com/Azure/azure-cli-dev-tools/blob/eee6d32a6653d639d01a23481063675f175e8b41/azdev/utilities/config.py#L24

dciborow avatar Feb 25 '23 22:02 dciborow

Have proposed fix here. https://github.com/Azure/azure-cli-dev-tools/pull/356

The code already contains a clause to return a value if the env_name was not determined, but the code is currently unreachable.

https://github.com/Azure/azure-cli-dev-tools/blob/eee6d32a6653d639d01a23481063675f175e8b41/azdev/utilities/config.py#L26-L27

Adding this if statement prevents the program from failing. https://github.com/Azure/azure-cli-dev-tools/blob/cf561895ad7f76d03fecb03ea8e96911fa9f62ba/azdev/utilities/config.py#L26

dciborow avatar Feb 25 '23 22:02 dciborow