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

tfswitch version 1.2.4 doesn't read .tfswitch.toml from current directory #533

Closed
krishna2vinayak opened this issue Jan 20, 2025 · 4 comments · Fixed by #534
Closed

tfswitch version 1.2.4 doesn't read .tfswitch.toml from current directory #533

krishna2vinayak opened this issue Jan 20, 2025 · 4 comments · Fixed by #534
Assignees

Comments

@krishna2vinayak
Copy link

krishna2vinayak commented Jan 20, 2025

Newest version of tfswitch doesn't read .tfswitch.toml from current working directory. It will only read if exist in home directory.

➜  /tmp ll tfswitch
-rwxr-xr-x  1 vinayak.krishna  wheel    11M Nov 23 04:19 tfswitch*

➜  /tmp cat .tfswitch.toml 
bin = "./terraform"
version = "1.10.4"

➜  /tmp rm ~/.tfswitch.toml
  
➜  /tmp ./tfswitch                                 
Use the arrow keys to navigate: ↓ ↑ → ← 
Select Terraform version
  ▸ 1.10.4 *recent
    1.10.3
    1.10.2
    1.10.1
↓   1.10.0

➜  /tmp cp .tfswitch.toml ~   

➜  /tmp ./tfswitch               
22:59:34.416 INFO Reading configuration from "/Users/vinayak.krishna/.tfswitch.toml"  
22:59:34.417 INFO Switched Terraform to version "1.10.4"  

➜  /tmp ll tfswitch terraform
lrwxr-xr-x  1 vinayak.krishna  wheel    59B Jan 20 22:59 terraform@ -> /Users/vinayak.krishna/.terraform.versions/terraform_1.10.4
-rwxr-xr-x  1 vinayak.krishna  wheel    11M Nov 23 04:19 tfswitch*

We use .tfswitch.toml in different directories to chose version per dir. This feature was working until version 1.1.1.

@MatthewJohn MatthewJohn self-assigned this Jan 20, 2025
@MatthewJohn
Copy link
Collaborator

Hey @krishna2vinayak ,

From looking at the changes - it seem like the only supported directory for the TOML file is the home directory.
It's set via an unmodifiable TomlDir attribute - perhaps this could be exposed as an cmdline param and/or an environment variable.
@warrensbox @yermulnik what do you think?

@yermulnik
Copy link
Collaborator

I think it makes sense to have TOML config file to belong in $HOME directory only.
Everything it supports, can be passed as command-line arguments.

@krishna2vinayak What's your use case? Do you need to pass the custom binary path or desired Terraform version only by means of configuration file?

@yermulnik
Copy link
Collaborator

yermulnik commented Jan 20, 2025

By the way, there was a discussion on this (among other items): #420
I guess eventually it was decided to keep TOML belonging in home directory only and see whether there will be users' interest in allowing it in current dir or in chdir arg.

UPD: Historically TOML in current dir or in chdir arg was meant to provide only version option. Though, given it provides a bunch of other options, the rationale behind it belonging to home dir only was to eliminate confusion of why other options take no action in non-home dir TOML.

@yermulnik
Copy link
Collaborator

PR to rectify the historical discrepancy: #534

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 a pull request may close this issue.

3 participants