Terraform v0.8.4
Expected behavior:
Error messages are readable on Windows consoles (PowerShell or Windows Command Shell)
Actual behavior:
Error messages are garbled with stdout output:
C:\platform-engineering\terraform\qlessenv\test1>terraform get -no-color
Get: file://C:/platform-engineering/terraform/qless/modules/vpc
Get: file://C:/platform-engineering/terraform/qless/modules/appserver
GEertr:o rf illoea:d/i/nCg: /Tpelrartaffoorrmm:- emnogdiunleee rrionogt/:t emrordaufloer mv/pqcl:e snsa/mmeo diusl enso/ta uar ovraal
id parameter
workaround for this issue is to redirect console output to anything
like "terraform get > c:\temp\temp.txt"
I can confirm experiencing this exact behavior. Also, this behavior appears to happens when a .terraform dir already exists. In my tests, deleting the .terraform dir, would eliminate the garble from the stdout output for 1 run until the directory was created again. Subsequent runs would show the garble returning.
Confirm that this is still happening in v.8.7
azEurrreorrm _avpiprltyuianlg_ mpalcahni:n
e
.1e le-rcrhoerf( s()l ooccaclu-rerxeedc:)
:
T*h ea zsuyrnetramx_ voifr ttuhael _cmoamcmhainnde .iesl -icnhceofr:r e1c te.r
ror(s) occurred:
* Error running command ' mkdir -p /c/tmp/vendored_cookbooks
cd /c/repos/cookbooks/chef
berks vendor /c/tmp/vendored_cookbooks
cd /c/repos/cookbooks/sql
berks vendor /c/tmp/vendored_cookbooks
': exit status 1. Output: The syntax of the command is incorrect.
Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.
This is a pleasure to deal with.
I successfully reproduced this on Windows 10, finally.

It seems like it's specifically _errors_ that get garbled, as opposed to other non-error output. That suggests it's either the red coloring of the text that's creating trouble or the fact that errors get written to stderr instead of stdout. My gut tells me the latter is the problem here since we seem to have no problem producing output of other colors, such as in the plan output shown here.
Plain text version of the above garble:
E:\tmp\modules-in-graph>e:\terraform apply
null_resource.foo: Refreshing state... (ID: 639599429235580741) null_resource.foo: Refreshing state... (ID: 7736919474868488810)
null_resource.foo: Destroying... (ID: 639599429235580741)
null_resource.foo: Destruction complete
null_resource.foo: Creating...
null_resource.foo: Provisioning with 'local-exec'...
nEurlrlo_rr easpopulrycien.gf opol a(nl:o
ca
l-1e xeercr)o:r (Esx)e couctciunrgr:e dc:m
d
*/ Cn u"lelx_irte s2o"u
rce.foo: 1 error(s) occurred:
* Error running command 'exit 2': exit status 2. Output:
Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.
I have narrowed this down to our use of colorable to fake out support for VT100 color codes on Windows.
On Windows we wrap a writer from that library around each of stderr and stdout and then write to those handles through those writers. Internally colorable deals with the data one rune at a time so that it can pick out the ESC[ introduction sequence and emit the relevant Windows console API calls to implement the escape sequence.
The problem is that even when stderr and stdout are actually the same underlying handle (the console) we still create two separate colorable wrappers, and concurrently write different buffers to each of them, causing their output to be interleaved.
This sort of interleaving is actually theoretically possible on other platforms too, but because we tend to write to stdout and stderr in whole lines it's normally only the _lines_ that can get interleaved. Colorable makes this a lot more visible by doing character-by-character writes to the console, allowing the interleaving to happen at the individual character level.
Thanks everyone for the patience here! This should be fixed in the next release.
I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Most helpful comment
Thanks everyone for the patience here! This should be fixed in the next release.