Atom-beautify: Terraform Fmt failing on .tf files

Created on 24 May 2019  路  18Comments  路  Source: Glavin001/atom-beautify

Description

Getting this error message when beautifying a .tf file:
"Only .tf and .tfvars files can be processed with terraform fmt"

Happening for all my .tf files.

Steps to Reproduce

  1. Add code to Atom editor
  2. Run command Atom Beautify: Beautify Editor
  3. Error is displayed

Package version: 0.33.4
Atom version: 1.37.0
OSX version: 10.14.5
Beatify on other file types seems to work fine.

Stack trace

Error: 
Error: Only .tf and .tfvars files can be processed with terraform fmt

    at /Users/username/.atom/packages/atom-beautify/src/beautifiers/executable.coffee:183:23
    at tryCatcher (/Users/username/.atom/packages/atom-beautify/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/username/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/Users/username/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/Users/username/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/Users/username/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:694:18)
    at _drainQueueStep (/Users/username/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:138:12)
    at _drainQueue (/Users/username/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:131:9)
    at Async._drainQueues (/Users/username/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:147:5)
    at Async.drainQueues (/Users/username/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:17:14)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

Checklist

I have:

  • [x] Tried uninstalling and reinstalling Atom Beautify to ensure it installed properly
  • [x] Reloaded (or restarted) Atom to ensure it is not a caching issue
  • [x] Searched through existing Atom Beautify Issues at https://github.com/Glavin001/atom-beautify/issues
    so I know this is not a duplicate issue
  • [x] Filled out the Input, Expected, and Actual sections above or have edited/removed them in a way that fully describes the issue.
  • [ ] Generated debugging information by executing Atom Beautify: Help Debug Editor command in Atom and added link for debug.md Gist to this issue

Most helpful comment

Same for me on terraform 0.12

All 18 comments

Same for me on terraform 0.12

I have the same issue.
Package version: 0.33.4
Atom version: 1.40.1 x64
OSX version: 10.13.6

Also failed beautifying my terraform code.

Severity    Provider    Description Line 
 Error: Only .tf and .tfvars files can be processed with terraform fmt




Error: Only .tf and .tfvars files can be processed with terraform fmt

Hide Stack Trace
Error: 
Error: Only .tf and .tfvars files can be processed with terraform fmt

    at /Users/username/.atom/packages/atom-beautify/src/beautifiers/executable.coffee:183:23
    at tryCatcher (/Users/username/.atom/packages/atom-beautify/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/username/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:517:31)
    at Promise._settlePromise (/Users/username/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:574:18)
    at Promise._settlePromise0 (/Users/username/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:619:10)
    at Promise._settlePromises (/Users/username/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:699:18)
    at _drainQueueStep (/Users/username/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:138:12)
    at _drainQueue (/Users/username/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:131:9)
    at Async._drainQueues (/Users/username/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:147:5)
    at Async.drainQueues (/Users/username/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:17:14)
    at run (/Users/username/.atom/packages/git-plus/node_modules/core-js/modules/es6.promise.js:75:22)
    at /Users/username/.atom/packages/git-plus/node_modules/core-js/modules/es6.promise.js:92:30
    at flush (/Users/username/.atom/packages/git-plus/node_modules/core-js/modules/_microtask.js:18:9)
    at process._tickCallback (internal/process/next_tick.js:61:11)

+1

+1

+1

Is there any update on this to be fixed?

+1

+1

+1

+1

Is there any solution for this problem by now?

+1

image

Sounds like he may be working on another project.

I've switched to Visual Studio Code and will likely stay. Worth giving a go.

FWIW you can apply the fix from the PR yourself by editing %HOMEPATH%\.atom\packages\atom-beautify\src\beautifiers\terraformfmt.coffee

  beautify: (text, language, options) ->
    @exe("terraform").run([
      "fmt"
-      tempFile = @tempFile("input", text)
+      tempFile = @tempFile("input", text, ".tf")
      ])

Might I also highly recommend you add -no-color to the args to make the lint messages more readable. (The garbage chars are from Terraform trying to add pretty shell colors)

  beautify: (text, language, options) ->
    @exe("terraform").run([
      "fmt"
+     "-no-color"
      tempFile = @tempFile("input", text, ".tf")
      ])

FWIW you can apply the fix from the PR yourself by editing %HOMEPATH%\.atom\packages\atom-beautify\src\beautifiers\terraformfmt.coffee

  beautify: (text, language, options) ->
    @exe("terraform").run([
      "fmt"
-      tempFile = @tempFile("input", text)
+      tempFile = @tempFile("input", text, ".tf")
      ])

Both this and your "-no-color" tip worked great for me. Thanks. Maybe it's time to submit a PR.

@lmasaya It already is actually, just needs a merge https://github.com/Glavin001/atom-beautify/pull/2351/files

Minus the no-color flag, but somehow I think this project is abandoned now.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

philippelesaux picture philippelesaux  路  4Comments

callmeyesh picture callmeyesh  路  3Comments

philiplb picture philiplb  路  5Comments

derwaldgeist picture derwaldgeist  路  4Comments

bartocc picture bartocc  路  5Comments