Repository: gruntwork-io/terragrunt (language: go)

Issue:
run-all plan runs init twice on the same module
Running 

```
terragrunt run-all plan
```

results in `init` being called twice, once at the start and then again after running the plan.

I've tried the latest and a couple of previous versions. My sample is very simple.

Anything that would cause this?

Log output below...

```
PS C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg> terragrunt run-all plan --terragrunt-log-level debug --terragrunt-debug
time=2023-04-06T08:02:12+01:00 level=debug msg=Did not find any locals block: skipping evaluation. prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=Detected single bare include block - exposing as top level prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=Detected single bare include block - exposing as top level prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=Detected single bare include block - exposing as top level prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=Found locals block: evaluating the expressions. prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=Evaluated 1 locals (remaining 0): subscription_id prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=[Partial] Included config C:/Users/PaulSmith/source/repos/Terragrunt/infrastructure/environments/terragrunt.hcl has strategy shallow merge: merging config in (shallow). prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=Setting download directory for module C:/Users/PaulSmith/source/repos/Terragrunt/infrastructure/environments/QA/primary/rg to C:/Users/PaulSmith/source/repos/Terragrunt/infrastructure/environments/QA/primary/rg/.terragrunt-cache
time=2023-04-06T08:02:12+01:00 level=debug msg=Stack at C:/Users/PaulSmith/source/repos/Terragrunt/infrastructure/environments/QA/primary/rg:
  => Module C:/Users/PaulSmith/source/repos/Terragrunt/infrastructure/environments/QA/primary/rg (excluded: false, assume applied: false, dependencies: [])
time=2023-04-06T08:02:12+01:00 level=info msg=The stack at C:/Users/PaulSmith/source/repos/Terragrunt/infrastructure/environments/QA/primary/rg will be processed in the following order for command plan:
Group 1
- Module C:/Users/PaulSmith/source/repos/Terragrunt/infrastructure/environments/QA/primary/rg


time=2023-04-06T08:02:12+01:00 level=debug msg=Module C:/Users/PaulSmith/source/repos/Terragrunt/infrastructure/environments/QA/primary/rg must wait for 0 dependencies to finish prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=Running module C:/Users/PaulSmith/source/repos/Terragrunt/infrastructure/environments/QA/primary/rg now prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=Did not find any locals block: skipping evaluation. prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=Detected single bare include block - exposing as top level prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=Found locals block: evaluating the expressions. prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=Evaluated 1 locals (remaining 0): subscription_id prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=[Partial] Included config C:/Users/PaulSmith/source/repos/Terragrunt/infrastructure/environments/terragrunt.hcl has strategy shallow merge: merging config in (shallow). prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=Running command: terraform --version prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=Terraform version: 1.4.4 prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=Reading Terragrunt config file at C:/Users/PaulSmith/source/repos/Terragrunt/infrastructure/environments/QA/primary/rg/terragrunt.hcl prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=Did not find any locals block: skipping evaluation. prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=Detected single bare include block - exposing as top level prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=Found locals block: evaluating the expressions. prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=Evaluated 1 locals (remaining 0): subscription_id prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=[Partial] Included config C:/Users/PaulSmith/source/repos/Terragrunt/infrastructure/environments/terragrunt.hcl has strategy shallow merge: merging config in (shallow). prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=Did not find any locals block: skipping evaluation. prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=Detected single bare include block - exposing as top level prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=Found locals block: evaluating the expressions. prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=Evaluated 1 locals (remaining 0): subscription_id prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=Included config C:/Users/PaulSmith/source/repos/Terragrunt/infrastructure/environments/terragrunt.hcl has strategy shallow merge: merging config in (shallow) for dependency. prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=Detected single bare include block - exposing as top level prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=Found locals block: evaluating the expressions. prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=Evaluated 1 locals (remaining 0): subscription_id prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=Found locals block: evaluating the expressions. prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=Evaluated 1 locals (remaining 0): subscription_id prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=Included config C:/Users/PaulSmith/source/repos/Terragrunt/infrastructure/environments/terragrunt.hcl has strategy shallow merge: merging config in (shallow). prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=Downloading Terraform configurations from file://C:/Users/PaulSmith/source/repos/Terragrunt/infrastructure/modules into C:/Users/PaulSmith/source/repos/Terragrunt/infrastructure/environments/QA/primary/rg/.terragrunt-cache/JIgFn6BPKOh3rQfg7rgbUpzb3NA/6i22O9zNwcBMrF5SQ1B4DAcLS5Q prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=Copying files from C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg into C:/Users/PaulSmith/source/repos/Terragrunt/infrastructure/environments/QA/primary/rg/.terragrunt-cache/JIgFn6BPKOh3rQfg7rgbUpzb3NA/6i22O9zNwcBMrF5SQ1B4DAcLS5Q/rg prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=Setting working directory to C:/Users/PaulSmith/source/repos/Terragrunt/infrastructure/environments/QA/primary/rg/.terragrunt-cache/JIgFn6BPKOh3rQfg7rgbUpzb3NA/6i22O9zNwcBMrF5SQ1B4DAcLS5Q/rg prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=Generated file C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg\.terragrunt-cache\JIgFn6BPKOh3rQfg7rgbUpzb3NA\6i22O9zNwcBMrF5SQ1B4DAcLS5Q\rg\versions.tf. prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=Generated file C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg\.terragrunt-cache\JIgFn6BPKOh3rQfg7rgbUpzb3NA\6i22O9zNwcBMrF5SQ1B4DAcLS5Q\rg\backend.tf. prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=info msg=Debug mode requested: generating debug file terragrunt-debug.tfvars.json in working dir C:/Users/PaulSmith/source/repos/Terragrunt/infrastructure/environments/QA/primary/rg/.terragrunt-cache/JIgFn6BPKOh3rQfg7rgbUpzb3NA/6i22O9zNwcBMrF5SQ1B4DAcLS5Q/rg prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=The following variables were detected in the terraform module: prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=[] prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=Variables passed to terraform are located in "C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg\terragrunt-debug.tfvars.json" prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=Run this command to replicate how terraform was invoked: prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg= terraform plan -input=false -var-file="C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg\terragrunt-debug.tfvars.json" "C:/Users/PaulSmith/source/repos/Terragrunt/infrastructure/environments/QA/primary/rg/.terragrunt-cache/JIgFn6BPKOh3rQfg7rgbUpzb3NA/6i22O9zNwcBMrF5SQ1B4DAcLS5Q/rg" prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=Initializing remote state for the azurerm backend prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=Running command: terraform init prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]

Initializing the backend...

Successfully configured the backend "azurerm"! Terraform will automatically
use this backend unless the backend configuration changes.

Initializing provider plugins...
- Finding hashicorp/azurerm versions matching "2.95.0"...
- Installing hashicorp/azurerm v2.95.0...
- Installed hashicorp/azurerm v2.95.0 (signed by HashiCorp)

Terraform has created a lock file .terraform.lock.hcl to record the provider
selections it made above. Include this file in your version control repository
so that Terraform can guarantee to make the same selections by default when
you run "terraform init" in the future.

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
time=2023-04-06T08:02:24+01:00 level=debug msg=Copying lock file from C:/Users/PaulSmith/source/repos/Terragrunt/infrastructure/environments/QA/primary/rg/.terragrunt-cache/JIgFn6BPKOh3rQfg7rgbUpzb3NA/6i22O9zNwcBMrF5SQ1B4DAcLS5Q/rg/.terraform.lock.hcl to C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:24+01:00 level=debug msg=Running command: terraform plan -input=false prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # azurerm_resource_group.example will be created
  + resource "azurerm_resource_group" "example" {
      + id       = (known after apply)
      + location = "uksouth"
      + name     = "RG-Terragrunt"
    }

Plan: 1 to add, 0 to change, 0 to destroy.

─────────────────────────────────────────────────────────────────────────────

Note: You didn't use the -out option to save this plan, so Terraform can't
guarantee to take exactly these actions if you run "terraform apply" now.
time=2023-04-06T08:02:37+01:00 level=debug msg=Module C:/Users/PaulSmith/source/repos/Terragrunt/infrastructure/environments/QA/primary/rg has finished successfully! prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:37+01:00 level=info msg=time=2023-04-06T08:02:12+01:00 level=debug msg=Running command: terraform --version prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=Generated file C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg\.terragrunt-cache\JIgFn6BPKOh3rQfg7rgbUpzb3NA\6i22O9zNwcBMrF5SQ1B4DAcLS5Q\rg\versions.tf. prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=Generated file C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg\.terragrunt-cache\JIgFn6BPKOh3rQfg7rgbUpzb3NA\6i22O9zNwcBMrF5SQ1B4DAcLS5Q\rg\backend.tf. prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=info msg=Debug mode requested: generating debug file terragrunt-debug.tfvars.json in working dir C:/Users/PaulSmith/source/repos/Terragrunt/infrastructure/environments/QA/primary/rg/.terragrunt-cache/JIgFn6BPKOh3rQfg7rgbUpzb3NA/6i22O9zNwcBMrF5SQ1B4DAcLS5Q/rg prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=The following variables were detected in the terraform module: prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=[] prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=Variables passed to terraform are located in "C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg\terragrunt-debug.tfvars.json" prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=Run this command to replicate how terraform was invoked: prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg= terraform plan -input=false -var-file="C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg\terragrunt-debug.tfvars.json" "C:/Users/PaulSmith/source/repos/Terragrunt/infrastructure/environments/QA/primary/rg/.terragrunt-cache/JIgFn6BPKOh3rQfg7rgbUpzb3NA/6i22O9zNwcBMrF5SQ1B4DAcLS5Q/rg" prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=Initializing remote state for the azurerm backend prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:12+01:00 level=debug msg=Running command: terraform init prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]

Initializing the backend...

Successfully configured the backend "azurerm"! Terraform will automatically
use this backend unless the backend configuration changes.

Initializing provider plugins...
- Finding hashicorp/azurerm versions matching "2.95.0"...
- Installing hashicorp/azurerm v2.95.0...
- Installed hashicorp/azurerm v2.95.0 (signed by HashiCorp)

Terraform has created a lock file .terraform.lock.hcl to record the provider
selections it made above. Include this file in your version control repository
so that Terraform can guarantee to make the same selections by default when
you run "terraform init" in the future.

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
time=2023-04-06T08:02:24+01:00 level=debug msg=Copying lock file from C:/Users/PaulSmith/source/repos/Terragrunt/infrastructure/environments/QA/primary/rg/.terragrunt-cache/JIgFn6BPKOh3rQfg7rgbUpzb3NA/6i22O9zNwcBMrF5SQ1B4DAcLS5Q/rg/.terraform.lock.hcl to C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
time=2023-04-06T08:02:24+01:00 level=debug msg=Running command: terraform plan -input=false prefix=[C:\Users\PaulSmith\source\repos\Terragrunt\infrastructure\environments\QA\primary\rg]
```


Discussion / hints:
The second `init` fails on build agents in Azure DevOps though it success locally. I can't work out why my guess is credentials aren't being set.

Fix patch:
diff --git a/cli/cli_app.go b/cli/cli_app.go
index 6e85a4eb17..9c846cbbfd 100644
--- a/cli/cli_app.go
+++ b/cli/cli_app.go
@@ -12,6 +12,7 @@ import (
 
 	"github.com/gruntwork-io/terragrunt/tflint"
 
+	"github.com/gruntwork-io/gruntwork-cli/collections"
 	"github.com/hashicorp/go-multierror"
 	"github.com/mattn/go-zglob"
 	"github.com/sirupsen/logrus"
@@ -105,17 +106,21 @@ var allTerragruntStringOpts = []string{
 	optTerragruntModulesThatInclude,
 }
 
-const CMD_INIT = "init"
-const CMD_INIT_FROM_MODULE = "init-from-module"
-const CMD_PROVIDERS = "providers"
-const CMD_LOCK = "lock"
-const CMD_TERRAGRUNT_INFO = "terragrunt-info"
-const CMD_TERRAGRUNT_VALIDATE_INPUTS = "validate-inputs"
-const CMD_TERRAGRUNT_GRAPH_DEPENDENCIES = "graph-dependencies"
-const CMD_TERRAGRUNT_READ_CONFIG = "terragrunt-read-config"
-const CMD_HCLFMT = "hclfmt"
-const CMD_AWS_PROVIDER_PATCH = "aws-provider-patch"
-const CMD_RENDER_JSON = "render-json"
+const (
+	CMD_INIT                          = "init"
+	CMD_INIT_FROM_MODULE              = "init-from-module"
+	CMD_PLAN                          = "plan"
+	CMD_APPLY                         = "apply"
+	CMD_PROVIDERS                     = "providers"
+	CMD_LOCK                          = "lock"
+	CMD_TERRAGRUNT_INFO               = "terragrunt-info"
+	CMD_TERRAGRUNT_VALIDATE_INPUTS    = "validate-inputs"
+	CMD_TERRAGRUNT_GRAPH_DEPENDENCIES = "graph-dependencies"
+	CMD_TERRAGRUNT_READ_CONFIG        = "terragrunt-read-config"
+	CMD_HCLFMT                        = "hclfmt"
+	CMD_AWS_PROVIDER_PATCH            = "aws-provider-patch"
+	CMD_RENDER_JSON                   = "render-json"
+)
 
 // START: Constants useful for multimodule command handling
 const CMD_RUN_ALL = "run-all"
@@ -1100,7 +1105,7 @@ func providersNeedInit(terragruntOptions *options.TerragruntOptions) bool {
 //
 // If terraformSource is specified, then arguments to download the terraform source will be appended to the init command.
 //
-// This method will return an error and NOT run terraform init if the user has disabled Auto-Init
+// This method will return an error and NOT run terraform init if the user has disabled Auto-Init.
 //
 // This method takes in the "original" terragrunt options which has the unmodified 'WorkingDir' from before downloading the code from the source URL,
 // and the "updated" terragrunt options that will contain the updated 'WorkingDir' into which the code has been downloaded
@@ -1137,8 +1142,12 @@ func prepareInitOptions(terragruntOptions *options.TerragruntOptions, terraformS
 	initOptions.WorkingDir = terragruntOptions.WorkingDir
 	initOptions.TerraformCommand = CMD_INIT
 
-	// Don't pollute stdout with the stdout from Auto Init
-	initOptions.Writer = initOptions.ErrWriter
+	initOutputForCommands := []string{CMD_PLAN, CMD_APPLY}
+	terraformCommand := util.FirstArg(terragruntOptions.TerraformCliArgs)
+	if !collections.ListContainsElement(initOutputForCommands, terraformCommand) {
+		// Since some command can return a json string, it is necessary to suppress output to stdout of the `terraform init` command.
+		initOptions.Writer = io.Discard
+	}
 
 	return initOptions, nil
 }


Test patch:
diff --git a/test/integration_test.go b/test/integration_test.go
index 9808adfdf0..2ca5a20379 100644
--- a/test/integration_test.go
+++ b/test/integration_test.go
@@ -3050,27 +3050,15 @@ func TestDataDir(t *testing.T) {
 	)
 
 	err := runTerragruntCommand(t, fmt.Sprintf("terragrunt plan --terragrunt-non-interactive --terragrunt-working-dir %s", rootPath), &stdout, &stderr)
-	erroutput := stderr.String()
-
-	if err != nil {
-		t.Errorf("Did not expect to get an error: %s", err.Error())
-	}
-
-	assert.Contains(t, erroutput, "Initializing provider plugins")
-
-	var (
-		stdout2 bytes.Buffer
-		stderr2 bytes.Buffer
-	)
-
-	err = runTerragruntCommand(t, fmt.Sprintf("terragrunt plan --terragrunt-non-interactive --terragrunt-working-dir %s", rootPath), &stdout2, &stderr2)
-	erroutput2 := stderr2.String()
+	require.NoError(t, err)
+	assert.Contains(t, stdout.String(), "Initializing provider plugins")
 
-	if err != nil {
-		t.Errorf("Did not expect to get an error: %s", err.Error())
-	}
+	stdout = bytes.Buffer{}
+	stderr = bytes.Buffer{}
 
-	assert.NotContains(t, erroutput2, "Initializing provider plugins")
+	err = runTerragruntCommand(t, fmt.Sprintf("terragrunt plan --terragrunt-non-interactive --terragrunt-working-dir %s", rootPath), &stdout, &stderr)
+	require.NoError(t, err)
+	assert.NotContains(t, stdout.String(), "Initializing provider plugins")
 }
 
 func TestReadTerragruntConfigWithDependency(t *testing.T) {
@@ -4637,8 +4625,7 @@ func TestNoMultipleInitsWithoutSourceChange(t *testing.T) {
 	err := runTerragruntCommand(t, fmt.Sprintf("terragrunt plan --terragrunt-non-interactive --terragrunt-working-dir %s", testPath), &stdout, &stderr)
 	require.NoError(t, err)
 	// providers initialization during first plan
-	errout := string(stderr.Bytes())
-	assert.Equal(t, 1, strings.Count(errout, "Terraform has been successfully initialized!"))
+	assert.Equal(t, 1, strings.Count(stdout.String(), "Terraform has been successfully initialized!"))
 
 	stdout = bytes.Buffer{}
 	stderr = bytes.Buffer{}
@@ -4647,8 +4634,7 @@ func TestNoMultipleInitsWithoutSourceChange(t *testing.T) {
 	require.NoError(t, err)
 	// no initialization expected for second plan run
 	// https://github.com/gruntwork-io/terragrunt/issues/1921
-	errout = string(stderr.Bytes())
-	assert.Equal(t, 0, strings.Count(errout, "Terraform has been successfully initialized!"))
+	assert.Equal(t, 0, strings.Count(stdout.String(), "Terraform has been successfully initialized!"))
 }
 
 func TestAutoInitWhenSourceIsChanged(t *testing.T) {
@@ -4672,8 +4658,7 @@ func TestAutoInitWhenSourceIsChanged(t *testing.T) {
 	err = runTerragruntCommand(t, fmt.Sprintf("terragrunt plan --terragrunt-non-interactive --terragrunt-working-dir %s", testPath), &stdout, &stderr)
 	require.NoError(t, err)
 	// providers initialization during first plan
-	errout := string(stderr.Bytes())
-	assert.Equal(t, 1, strings.Count(errout, "Terraform has been successfully initialized!"))
+	assert.Equal(t, 1, strings.Count(stdout.String(), "Terraform has been successfully initialized!"))
 
 	updatedHcl = strings.Replace(contents, "__TAG_VALUE__", "v0.35.2", -1)
 	require.NoError(t, ioutil.WriteFile(terragruntHcl, []byte(updatedHcl), 0444))
@@ -4684,8 +4669,7 @@ func TestAutoInitWhenSourceIsChanged(t *testing.T) {
 	err = runTerragruntCommand(t, fmt.Sprintf("terragrunt plan --terragrunt-non-interactive --terragrunt-working-dir %s", testPath), &stdout, &stderr)
 	require.NoError(t, err)
 	// auto initialization when source is changed
-	errout = string(stderr.Bytes())
-	assert.Equal(t, 1, strings.Count(errout, "Terraform has been successfully initialized!"))
+	assert.Equal(t, 1, strings.Count(stdout.String(), "Terraform has been successfully initialized!"))
 }
 
 func TestRenderJsonAttributesMetadata(t *testing.T) {