terraformsh icon indicating copy to clipboard operation
terraformsh copied to clipboard

Too many command line arguments error

Open riisi opened this issue 11 months ago • 3 comments

Thanks for this 'framework' - I really like the approach and I'm surprised it's not used more widely.

I'm getting this error:

../../terraformsh apply
../../terraformsh: Info: Found terraform command 'apply'
../../terraformsh: Warning: No -b option passed! Potentially using only local state.

+ terraform init -input=false -reconfigure -force-copy

Initializing the backend...

Initializing provider plugins...
- Finding latest version of hashicorp/local...
- Installing hashicorp/local v2.4.1...
- Installed hashicorp/local v2.4.1 (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!
+ terraform apply  -input=false /Users//repos/terraformsh/tests/local-file-hello-world.tfd/tf.7939dcb43b.plan
╷
│ Error: Too many command line arguments
│ 
│ Expected at most one positional argument.
╵

For more help on using this command, run:
  terraform apply -help

It occurs when varfiles is empty (as it should be on apply) - there is an additional space inserted. I think it may have been introduced after the last release.

To reproduce:

cd tests/local-file-hello-world.tf
../../terraformsh apply

For now, I'm working around by patching _runcmd () to trim spaces - but there may be a better solution:

_runcmd () {
    echo "+ $*" 1>&2

    CMD=$(echo "$@" | tr -s " ")

    if [ ! "${DRYRUN:-0}" = "1" ] ; then bash -c "$CMD"; fi
}

riisi avatar Feb 28 '24 23:02 riisi

@riisi thanks very much for the bug report! Sorry about taking so long to get to it, I'll definitely take a whack at it this weekend

peterwwillis avatar Mar 07 '24 23:03 peterwwillis

@riisi apologies again for taking so long to look at this :( can you confirm for me your shell, shell version, and terraform version? i'm having some trouble reproducing your error

also i notice in your output, your path has /Users//repos/, which i assumed was just redacting username, but if it was unintentional, maybe it's a hint to the error?

peterwwillis avatar Apr 07 '24 21:04 peterwwillis

@riisi nevermind, i reproduced it! will work out a fix

peterwwillis avatar Apr 07 '24 21:04 peterwwillis