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

Windows console output unreadable #11363

Closed
dlgasser opened this issue Jan 23, 2017 · 8 comments · Fixed by #14194
Closed

Windows console output unreadable #11363

dlgasser opened this issue Jan 23, 2017 · 8 comments · Fixed by #14194

Comments

@dlgasser
Copy link

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\qless\env\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

@yellowmew
Copy link

yellowmew commented Jan 24, 2017

workaround for this issue is to redirect console output to anything
like "terraform get > c:\temp\temp.txt"

@samirageb
Copy link
Contributor

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.

@samirageb
Copy link
Contributor

Confirm that this is still happening in v.8.7

@glennmate
Copy link

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.

@apparentlymart
Copy link
Contributor

apparentlymart commented May 3, 2017

I successfully reproduced this on Windows 10, finally.

terraform-windows-garble

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.

@apparentlymart
Copy link
Contributor

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.

@apparentlymart
Copy link
Contributor

Thanks everyone for the patience here! This should be fixed in the next release.

@ghost
Copy link

ghost commented Apr 13, 2020

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.

@ghost ghost locked and limited conversation to collaborators Apr 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants