Introduction
This article explains the reason why users are getting Permission Denied
while running packer init .
or packer plugins install github.com/hashicorp/<plugin_name>
and how to resolve this issue.
Problem
Getting this error message while installing the plugins,
Couldn't setup logging tempfile: open /tmp/packer-log4219315924: permission denied
Cause
Plugin installation requires access to a temporary file directory. It is defined as environment variables - TMPDIR (Unix) / TMP, TEMP, USERPROFILE (Windows) and defaulting to /tmp on Linux/Unix and %USERPROFILE%\AppData\Local\Temp on Windows Vista and later.
If the system's temp directory is non-writable or non-executable, update the environment variable for the temporary directory to override the location of the temporary file store used by Packer.
Solutions
-
Update the temporary folder's permission to be writable and executable.
- If the system Packer is running on follows CIS Standards, change the temporary folder path by these commands,
mkdir ~/.tmp/
export TMPDIR=~/.tmp/