I used some CMDs to call packer because my json file contains conditional logic to include and exclude specific steps depending on the build type.
After losing a lot of hair I did exactly the same command lines directly in PowerShell and CMD and looked at verbose package debug output.
Under CMD the single quotes are retained, but not under PowerShell.
I use CMDs because they can be activated directly in the explorer shell and are sufficient for simply providing various arg sets to the same .json.
Packer log for powershell shows:
variable:value
While packer log for cmd.exe shows:
'variable:value'
Thanks for the report. I think this may be an idiosyncrasy of the shell or of go's flag parsing, and not specific to packer. Do you have the same problem if you use double quotes instead of single quotes?
Never got more info; closing. If anyone has more to say, feel free to reopen.
I've been hit by (what might be) this today. The examples in the docs show single quotes being used:
$ packer build \ -var 'aws_access_key=foo' \ -var 'aws_secret_key=bar' \ template.json
If I have a variables block defined as:
"variables":{
"a":null
}
And call it thusly, as per the docs, on the windows command line:
packer build -var 'a=foo' test.json
I get:
- required variable not set: a
Using double quotes works normally:
packer build -var "a=foo" test.json
The single quote version also works normally within a powershell prompt.
I have seen this bug too
@JamesThorpe Thanks for the steps to reproduce; I know we have a PR waiting on 1.2.0 (here) that will change some of the powershell variable handling so I'm reopening this until I get a chance to test your repro case against that PR; if that PR fixes it I'll close again.
I've experienced the same issue as @JamesThorpe when using both cmd.exe
and PowerShell
on Windows 10. Was this ever solved?
I've been hit by (what might be) this today. The examples in the docs show single quotes being used:
$ packer build \ -var 'aws_access_key=foo' \ -var 'aws_secret_key=bar' \ template.json
If I have a variables block defined as:
"variables":{ "a":null }
And call it thusly, as per the docs, on the windows command line:
packer build -var 'a=foo' test.json
I get:
- required variable not set: a
Using double quotes works normally:
packer build -var "a=foo" test.json
The single quote version also works normally within a powershell prompt.
I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Most helpful comment
@JamesThorpe Thanks for the steps to reproduce; I know we have a PR waiting on 1.2.0 (here) that will change some of the powershell variable handling so I'm reopening this until I get a chance to test your repro case against that PR; if that PR fixes it I'll close again.