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

Ensure download location exists before listing installed terraform versions #14

Conversation

mmourick
Copy link
Collaborator

@mmourick mmourick commented Mar 4, 2024

What

Ensures download location exists before listing installed terraform versions.

Why

To prevent error listing installation directory from happening when an user lists installed terraform versions before having downloaded any.

References

@bschaatsbergen
Copy link
Collaborator

bschaatsbergen commented Mar 4, 2024

If you try to use the command $ tfversion list --installed on a fresh machine, should it show an error? Wouldn't it be better if it just gives back an empty list because nothing is installed? Is it necessary to show an error message in this situation?

@mmourick
Copy link
Collaborator Author

mmourick commented Mar 4, 2024

@bschaatsbergen What this pr does is prevent an error being thrown as a result of the download directory not yet being created.

The following no longer occurs on a fresh installation:

tfversion list --installed
error listing installation directory: open /Users/mathijs/.tfversion: no such file or directory

However, with this fix in place, the user is still presented with this error:

tfversion list --installed
error listing installed versions: no versions found

This error message already is much more clear to the user and probably was meant to be displayed to the user in this scenario, so it's definitely an improvement.
However, I agree it does not warrant an error message. If you want I can update that behavior as well in this PR. I had left it out since I figured the above was the desired behavior.

Copy link
Collaborator

@ChrisTerBeke ChrisTerBeke left a comment

Choose a reason for hiding this comment

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

Ensuring the location exists in the GetDownloadLocation() method seems like the right solution to me. What do you think @bschaatsbergen?

@ChrisTerBeke ChrisTerBeke merged commit 6064fa6 into tfversion:main Mar 5, 2024
4 checks passed
@mmourick mmourick deleted the fix/ensure-download-location-exists-before-listing-installed-versions branch March 7, 2024 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tfversion list --installed produces an error on clean installation.
3 participants