Problem
When working on Windows with a volume mounted only as a folder path and not a drive letter, the terraform init command fails with the following error:
EvalSymlinks: too many links
This failure prevents Terraform from performing subsequent operations such as plan and apply.
Prerequisites
- Microsoft Windows
- Terraform for Windows (32-bit or 64-bit)
Cause
During the terraform init process, Terraform creates symbolic links (symlinks). Terraform is developed using the Go programming language and relies on the standard Go library for resolving these symlinks.
The standard Go library's implementation for this function on Windows depends on the volume where the symlink is created having an assigned drive letter, such as D:. When a volume is only mounted as a folder, this dependency is not met, causing the operation to fail.
Solutions
There are two primary solutions to resolve this issue.
Solution 1: Assign a Drive Letter to the Volume
You can resolve the error by assigning a drive letter to the volume in addition to its existing folder mount point.
- Open Computer Management.
- In the left pane, select Disk Management under the Storage category.
- In the main pane, right-click on the volume that is currently mounted only as a folder.
- Select Change Drive Letter and Paths... from the context menu.
- Click Add... and assign an available drive letter to the volume.
Solution 2: Use Windows Subsystem for Linux (WSL)
As an alternative, you can use the Linux version of Terraform within the Windows Subsystem for Linux (WSL). The Linux version of the Go library does not have the same drive letter dependency, allowing terraform init to complete successfully.
Outcome
After implementing one of the solutions, the terraform init command will complete successfully in a directory on the affected volume, allowing you to proceed with your Terraform workflow.
Additional Information
- This behavior is tracked in the upstream Terraform project in GitHub Issue #29483.
- For more information on installing and using WSL, refer to the official WSL documentation.