1

I am using PowerShell ISE and when I get an error, this weird timestamp is leading the error message and this is starting to get annoying.

Command:

PS C:\Users\serhat> terraform plan -var="ENVIRONMENT=Test" -var="POSTFIX=test" -var="PROJECT=common"

Output:

terraform : [31mâ•·[0m[0m
At line:1 char:1
+ terraform plan -var="ENVIRONMENT=Test" -var="POSTFIX=test" -var="PROJ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: ([31mâ•·[0m[0m:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError

[31m│[0m [0m[1m[31mError: [0m[0m[1mNo configuration files[0m
[31m│[0m [0m
[31m│[0m [0m[0mPlan requires configuration to be present. Planning without a configuration
[31m│[0m [0mwould mark everything for destruction, which is normally not what is
[31m│[0m [0mdesired. If you would like to destroy everything, run plan with the
[31m│[0m [0m-destroy option. Otherwise, create a Terraform configuration file (.tf
[31m│[0m [0mfile) and try again.
[31m╵[0m[0m

How do prevent this weird timestamp [31m│[0m [0m[1m[31m from appearing in all my ouputs?

PS: I am seeking for a permanent solution as I don't want to run a regex everytime I run a script.

mklement0
  • 382,024
  • 64
  • 607
  • 775
Serhat
  • 216
  • 2
  • 17
  • 3
    Those aren't time stamps. They're ANSI terminal escape codes for setting text attributes like `red`,`bold`,`normal` etc. I've no idea why they should be showing up on your system, but look at the ISE configuration options. – Tangentially Perpendicular Jun 09 '23 at 09:04
  • 1
    Thank you for the information. I think you are correct. They are color codes but looking like a timestamp. Setting terraform's variable`TF_CLI_ARGS="-no-color"` in computer's environment variables seems to have resolved the issue. – Serhat Jun 09 '23 at 10:31
  • 1
    As an aside: The PowerShell ISE is [no longer actively developed](https://docs.microsoft.com/en-us/powershell/scripting/components/ise/introducing-the-windows-powershell-ise#support) and [there are reasons not to use it](https://stackoverflow.com/a/57134096/45375) (bottom section), notably not being able to run PowerShell (Core) 6+. The actively developed, cross-platform editor that offers the best PowerShell development experience is [Visual Studio Code](https://code.visualstudio.com/) with its [PowerShell extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.PowerShell). – mklement0 Jun 09 '23 at 12:10
  • Amazing side-note @mklement0 . Thank you for that! I will try to switch to VS Code then. – Serhat Jun 09 '23 at 13:11
  • 1
    Glad to hear it, @Serhat, but please note that if you're using _Windows PowerShell_ you'll need the latest and last version, v5.1 – mklement0 Jun 09 '23 at 15:58

1 Answers1

3

To disable Terraform's colored output, pass the -no-color switch for a single command. One can also set up an environment variable TF_CLI_ARGS="-no-color" in case a global supression is needed.

vonPryz
  • 22,996
  • 7
  • 54
  • 65
  • Setting `TF_CLI_ARGS="-no-color"` in computer's environment variables seems to have resolved the issue permanently without specifying `-no-color` in every command. Thank you! @vonPryz – Serhat Jun 09 '23 at 10:29