New terrafrom import fails with "Error: Too many command line arguments"

Hi!
I am following along the new Terraform Import Tutorial
I have the latest TF 1.5.5 installed, and docker desktop running with the required image, but the step: tf plan -generate-config-out=generated.tf fails with:

│ Error: Too many command line arguments

│ To specify a working directory for the plan, use the global -chdir flag.

Any idea what is wrong here? Which additional traces would be needed?

Thank!
-Jörg

I checked the output of the terraform command with TRACE debug level enabled and found:

2023-08-10T08:52:00.165+0200 [INFO] CLI command args: string{“plan”, “-generate-config-out=generated”, “.tf”}

It seems that the extension is split of the filename ?!

So I tried tf plan -generate-config-out="generated.tf" and it works!

This should be noted in the tutorial / manual pages or is it a bug on the latest terraform cli version?

PS. I am using terraform on my windows 10 machine…

I think I have heard of PowerShell doing mad stuff like this. Try using a different shell, or live with needing extra quotes that most people don’t.

Yes, this is specifically PowerShell behavior. I think it tries to parse the flags as parameters itself first, and since . isn’t an allowed character it splits that into a separate argument. There no real solution other than to use the appropriate quoting for your shell to ensure arguments are passed to the program as expected. This applies to any program that’s not a natively written to work within PowerShell, not just Terraform.