profile
viewpoint

Ask questionsterraform fmt on save not actually occurring

If have Format on Save enabled, and on saving a .tf file, the output shows it running terraform fmt on the file:

2019-03-29 15:15:41:274 [INFO ] formatting-provider: running 'terraform fmt' on 'c:\Users\user\project-dir\main.tf'
2019-03-29 15:15:41:275 [INFO ] runner: Running terraform cwd='C:\Users\user\AppData\Local\Programs\Microsoft VS Code' path='terraform' (version: 0.11.11) args=[fmt, -]
2019-03-29 15:15:42:492 [INFO ] file-system-watcher: Indexed file:///c%3A/Users/user/project-dir/main.tf
2019-03-29 15:15:44:340 [INFO ] runner: Running terraform succeeded.

However, the formatting is not applied and file remains unchanged.

Running terraform fmt on the file via the console has the expected formatting effect on the file.

This issue was also mentioned by @IronFarm in https://github.com/mauve/vscode-terraform/issues/62#issuecomment-426944230

mauve/vscode-terraform

Answer questions udondan

Anyone found a solution or knows the cause? I'm having this problem since some weeks and can't find a solution. The Terraform output window shows it is running but nothing happens with the document.

2019-11-18 09:01:37:238 [INFO ] formatting-provider: running 'terraform fmt' on '/path/to/file.tf'
2019-11-18 09:01:37:238 [INFO ] runner: Running terraform cwd='/' path='/usr/local/bin/terraform' (version: 0.12.15) args=[fmt, -]
2019-11-18 09:01:38:189 [INFO ] runner: Running terraform succeeded.

I'm confused about the args: args=[fmt, -]

Is the 2nd arg a placeholder for the filename? Or is that the issue?

useful!

Related questions

Terraform v0.12.3 - Syntax check broken: Unknown token IDENT hot 2
feat: Terraform 0.12 support (was hcl2 support) hot 1
terraform.tfvars An argument named "xxx" is not expected here. hot 1
feat: Terraform 0.12 support (was hcl2 support) hot 1
Valid use of "resource for_each" in configuration causes VS Code peek problem hot 1
Terraform 0.12 linting also breaks formatting? hot 1
Installing language server errors when terraform is not found - vscode-terraform hot 1
source:https://uonfu.com/
Github User Rank List