Introduction
Terraform Cloud and Terraform Enterprise are designed as an execution platform for Terraform, and perform Terraform runs in their own disposable virtual machines called workers. When executing a remote Terraform run the worker will not have access to resources outside the content uploaded to the workspace (e.g. the content of a connected VCS repository).
Problem
Terraform runs within Terraform Cloud or Terraform Enterprise will fail with an error message like:
Setup failed: Failed to copy slug dir: lstat /some_path no such file or directory
Setup failed: Failed to copy slug dir: EvalSymlinks: too many links
failed pulling filesystem: ssh: failed scanning message: expected integer
Cause
The Terraform working directory in the Terraform worker contains broken symbolic links (symlinks). Symlinks that point outside the repository uploaded to Terraform Cloud or Terraform Enterprise will be broken as they point to sources which are not available to the worker.
The broken symlinks could be either in the configuration uploaded to the workspace or in a Terraform module that has been downloaded during the Terraform run.
In case of broken symlinks directly in the uploaded configuration the displayed error message is like
Setup failed: Failed to copy slug dir: lstat /some_path no such file or directory
Setup failed: Failed to copy slug dir: EvalSymlinks: too many links
If the broken links are located in a sub module downloaded during the remote Terraform run, the error message is like
failed pulling filesystem: ssh: failed scanning message: expected integer
Solution
Check the repository which is uploaded to Terraform Cloud or Terraform Enterprise and the referenced Terraform modules for broken links and fix or remove them.
The following commands can be used to find symlinks on a Unix-like system
find . -type l