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

local-exec provisioner silently fails when running on Windows with >8191 character command #35832

Open
immybo opened this issue Oct 9, 2024 · 1 comment
Labels
bug new new issue not yet triaged provisioner/local-exec

Comments

@immybo
Copy link

immybo commented Oct 9, 2024

Terraform Version

Terraform v1.9.7
on windows_amd64

Terraform Configuration Files

resource "terraform_data" "long_exec" {
  provisioner "local-exec" {
    interpreter = ["bash", "-c"]
    command = <<-EOC
    echo ThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongString;
    echo Hello
    EOC
  }
}

Debug Output

terraform_data.long_exec (local-exec): Executing: ["bash" "-c" "echo (most of string omitted from paste)ThisIsAVeryLongStringThisIsAVeryLongStringThisIsAVeryLongString;\r\necho Hello\r\n"]
terraform_data.long_exec (local-exec): (most of string omitted from paste)ThisIsAVeryLongStringThisIsAVeryL

Expected Behavior

The command should have failed with an error.

Actual Behavior

The command was cut off at the 8191 character limit of cmd.exe. See the output above ending with "ThisIsAVeryL" and not including the "echo hello", despite the command including it.

The actual use-case where we encountered this bug was using "echo $foo > $bar" where $foo was a very long string, and in this case it printed the first 8181 characters of $foo rather than writing them to $bar.

Steps to Reproduce

  1. terraform init
  2. terraform apply

Additional Context

Terraform is being run inside git bash.

Bash also has a limit, but "getconf ARG_MAX" returns 32000 both inside git bash and inside the interpreter command which is well above the amount of characters we're passing in even when you include "env | wc -c".

References

No response

@immybo immybo added bug new new issue not yet triaged labels Oct 9, 2024
@crw
Copy link
Collaborator

crw commented Oct 9, 2024

Thanks for this feature request! If you are viewing this issue and would like to indicate your interest, please use the 👍 reaction on the issue description to upvote this issue. We also welcome additional use case descriptions.

Just as an FYI, new development is not likely to happen on provisioners. Please see https://developer.hashicorp.com/terraform/language/resources/provisioners/syntax#provisioners-are-a-last-resort and https://github.com/hashicorp/terraform/blob/main/.github/CONTRIBUTING.md#provisioners. I am happy to leave this issue open in case we do decide to support provisioner-like functionality outside of providers at some point in the future.

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug new new issue not yet triaged provisioner/local-exec
Projects
None yet
Development

No branches or pull requests

2 participants