Closed domoran closed 2 years ago
Adding the path explicitly to the packer call works around the problem:
resource "packer_image" "test" {
environment = {
path = "C:\\Program Files\\Docker\\Docker\\resources\\bin"
}
file = "bug.pkr.hcl"
}
Thanks for your report.
Please try the keep_environment
attribute. If you set it to true, all env variables should get passed through.
Yes, that could serve as a workaround. However this "keep_environment" variable does exist and is turned off by default for a reason - in that case the packer provider does not work as expected, because it assumes packer to be on the path but allows the PATH to be empty.
So my suggestion would be to set sane defaults for PATH and for "TMP" so, that the provider works as exepected. Alternatively we could also put a big hint in the docs to use the keep_environment variable under windows. Not sure how the behaviour under linux is?
What do you think?
... in that case the packer provider does not work as expected, because it assumes packer to be on the path but allows the PATH to be empty
In cases where Packer doesn't need external tools (which is the case for most if not all cloud deployments), having no environment passed through works fine.
... So my suggestion would be to set sane defaults for PATH and for "TMP" so, that the provider works as exepected.
That's a good suggestion but the problem here is that it's difficult to really determine for all platforms which environment variables are considered "sane" defaults and which are not.
Not sure how the behaviour under linux is?
While Linux would be able to have the same problem, it appears as though usually Windows users are affected.
What do you think?
I think the best solution is to set keep_environment
to true by default and allow turning it off in case it's necessary.
Coming back to another point
in that case the packer provider does not work as expected, because it assumes packer to be on the path
Packer is embedded in the provider itself so Packer does not actually need to be in the path. And even if it is, it is not used.
Short Description: When invoking packer via terraform under windows, the path settings seem not to be inherited correctly from the terraform process to the packer process. This yields to a "docker not found in path problem" (but also other potential problems), when building packer images.
My Environment:
Steps to reproduce:
Expected behaviour:
Observed behaviour:
I attached the example files and the cmd log to the issue.
main.tf.txt bug.pkr.hcl.txt log.txt