Error: too many command line arguments is one more common error which obviously points out an issue related to arguments not being interpreted correctly. Although there’s no universal solution, I’ll share with you some ideas on how to resolve it.
1. Try to set the debugging env var
TRACE first, for instance:
run init, plan, apply, or whatever is causing the issue command again, double-check the argument names and values.
2. One time when I did get the following error:
╷ │ Error: Too many command line arguments │ │ │ To specify a working directory for the plan, use the global -chdir flag. ╵
was while trying to run
terraform plan -out=tfplan on a Windows machine. So, I had to replace the equal (=) sign with a space e.g.
terraform plan -out tfplan. The error message doesn’t say much since I was already in the working directory.
3. Syntax issues including:
- Trying to pass an invalid variable values – an unsupported, empty or non-ASCII characters.
- Not properly wrapping var values with single or double quotes.
- Formatting issues – /t (tab) spaces, extra spaces.
Whatever the case might be, try running
terraform fmt in the Terraform working directory.
4. Passing environment variables the wrong way as a part of terraform init bash script.
Based on these possible solutions, if you are still having hard time please leave a comment below, and I’ll try to help you with. On a side note, follow our official channel on Telegram.