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

{Misc.} az --version: Show config directory location #30662

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/azure-cli-core/azure/cli/core/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ def _get_local_versions():

def get_az_version_string(use_cache=False): # pylint: disable=too-many-statements
from azure.cli.core.extension import get_extensions, EXTENSIONS_DIR, DEV_EXTENSION_SOURCES, EXTENSIONS_SYS_DIR
from azure.cli.core._environment import get_config_dir
import io
output = io.StringIO()
versions = _get_local_versions()
Expand Down Expand Up @@ -410,6 +411,7 @@ def _get_version_string(name, version_dict):
_print()

_print("Python location '{}'".format(os.path.abspath(sys.executable)))
_print("Config directory '{}'".format(get_config_dir()))
Copy link
Member Author

Choose a reason for hiding this comment

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

Calling get_config_dir() is the official way of retrieving Azure CLI's config dir. azure.cli.core.auth.identity.Identity also uses it:

Copy link
Member Author

Choose a reason for hiding this comment

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

Another way to get config dir is from azure.cli.core.AzCli.config.config_dir, but this requires a AzCli instance which may not always be available.

_print("Extensions directory '{}'".format(EXTENSIONS_DIR))
if os.path.isdir(EXTENSIONS_SYS_DIR) and os.listdir(EXTENSIONS_SYS_DIR):
_print("Extensions system directory '{}'".format(EXTENSIONS_SYS_DIR))
Expand Down
Loading