-
Notifications
You must be signed in to change notification settings - Fork 95
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
Remove / move ensure_dir
call since it might cause some issues and not consistent
#277
Comments
Btw, I can try to contribute a fix back. Just curious about the bigger picture / context so that we don't break some upstream dependencies that already expect this behavior (why?). |
Disclaimer: It's been several years since I last worked on this project. However, reading through your analysis, I'm not sure why in https://github.com/microsoft/knack/pull/91/files, it was added where it was. Yes it seems it'd be best to have the call to ensure_dir() in CLIConfig#init happen a few lines down after |
Thanks @derekbekoe ! That's right it would be better (I think). But I don't quite understand the need for it anyways ... it would be still breaking some scenarios even a few lines below AFAI can tell. |
Removing the check altogether may make sense. One consideration is Removing that line could be a breaking change for people that depended on this library doing that check for them. Azure CLI does in-fact do its own check anyway though - https://github.com/Azure/azure-cli/blob/aee788b9c61b7982a5c8e7807d86d764c7f7a798/src/azure-cli-core/azure/cli/core/__init__.py#L78C31-L78C31. Just something else to consider. |
Thanks @derekbekoe for the research. Since it's a small change I would leave this decision to maintainers (I can do a PR if that makes sense).
I've seen that it is also using E.g. I've tried
And even |
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
The text was updated successfully, but these errors were encountered: