Terraform complains with "EvalSymlinks: too many links" when on a Windows roaming profile

Posted in development on January 31, 2024 by Adrian Wyssmann ‐ 2 min read

Working with terraform on Windows can be a pain, even more when using

Problem

While try to do a terraform init you get the following error

│ Error: Failed to install provider
│
│ Error while installing hashicorp/azurerm v3.83.0: failed to compute
│ checksum for
│ C:\Users\papa~1\AppData\Local\Temp\4\terraform-provider1701116033:
│ EvalSymlinks: too many links

The problem seem to occur if the profile is a roaming user profiles.

Solution

Use Local Folder

This happens on Windows servers, where the profile is not local. To fix it you need a local folder where you have read access, and then configure the following variables either in PS or bash

  • TEMP
  • TMP
  • TF_PLUGIN_CACHE_DIR
export TEMP=/c/c/Users/papanito/temp
export TMP=$TEMP
export TF_PLUGIN_CACHE_DIR=$TMP

Not sure if TF_PLUGIN_CACHE_DIR is really needed, but setting only this variable is not enough

You might need additional permissions to do so. Also using the same shared TEMP folders with others is probably not the best idea.

Subst Temp Folder

A better idea might be to set the temp folder to a separate drive using subst. Then configure the TEMP environment variable accordingly. So in powershell

subst E: C:\Users\papanito\AppData\Local\Temp\
$Env:TMP="E:\"

The assignment of the letter is not permanent and will be gone after a system reboot.

Turning a folder into a drive letter

Another solution could be Turning a folder into a drive letter - Microsoft Community. However I did not test this one.