-
Notifications
You must be signed in to change notification settings - Fork 96
Description
This code:
https://github.com/microsoft/knack/blob/dev/knack/config.py#L39-L44
is causing a bunch of potential issues:
-
If it's using the
_DEFAULT_CONFIG_DIR
that is trying to expand~
it will break on systems where a system user is used w/o a home dir. Error will look likePermission Error /nonexistent
(~
expands intononexistent
on such systems). I see that it's regular a practice to useos.path.expanduser(os.path.join('~', '.{}'.format('cli')))
or similar across Azure tools, but it's causing these errors. -
If config dir is taken from an env variable down the code, we never run
ensure_dir
on it (at least on read), which might also cause same issues as were the reason to add it in the first place?
For the context, it was added here #91. Discussion is here Azure/azure-cli#5001 (comment) . @derekbekoe may be you can give some insights on why it was the best place to resolve the initial issue, I don't have enough context to connect the dots yet.
I think we can try to do it in way that it's not needed for readonly mode (it just means that config is empty and tries to use env), for writes it should try to create it a fail. I see that we already have in:
https://github.com/microsoft/knack/blame/dev/knack/config.py#L223-L224