Skip to content

Remove / move ensure_dir call since it might cause some issues and not consistent  #277

Description

This code:

https://github.com/microsoft/knack/blob/dev/knack/config.py#L39-L44

is causing a bunch of potential issues:

  1. 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 like Permission Error /nonexistent (~ expands into nonexistent on such systems). I see that it's regular a practice to use os.path.expanduser(os.path.join('~', '.{}'.format('cli'))) or similar across Azure tools, but it's causing these errors.

  2. 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) . Derek Bekoe (@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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions