Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to install provider On Windows , PATH MAX LIMIT #28218

Open
elhadrio opened this issue Mar 27, 2021 · 1 comment
Open

Failed to install provider On Windows , PATH MAX LIMIT #28218

elhadrio opened this issue Mar 27, 2021 · 1 comment

Comments

@elhadrio
Copy link

elhadrio commented Mar 27, 2021

terraform fails to download the providers exe if the exe local path exceeds the windows default path limits 260.
below two examples that were failing.

D:\Terragrunt\TERRAGRUNT-EXAMPLE\.terragrunt-cache\GnjRrmlHLEossfvW8K1BLYF-j9o\p8RjqOBWuZlKpfg3qiYX6niuHqs\modules\powercard\parent_module_v4\.terraform\providers\registry.terraform.io\hashicorp\kubernetes\2.0.3\windows_amd64\terraform-provider-kubernetes_v2.0.3_x5.exe D:\Terragrunt\TERRAGRUNT-EXAMPLE\.terragrunt-cache\GnjRrmlHLEossfvW8K1BLYF-j9o\p8RjqOBWuZlKpfg3qiYX6niuHqs\modules\powercard\parent_module_v4\.terraform\providers\registry.terraform.io\hashicorp\random\3.1.0\windows_amd64\terraform-provider-random_v3.1.0_x5.exe

Terraform Version

v0.14.7

Crash Output

Error: Failed to install provider

Error while installing hashicorp/kubernetes v2.0.3: open
.terraform\providers\registry.terraform.io\hashicorp\kubernetes\2.0.3\windows_amd64\terraform-provider-kubernetes_v2.0.3_x5.exe:
Le chemin d’accès spécifié est introuvable.

Error: Failed to install provider

Error while installing hashicorp/template v2.2.0: open
.terraform\providers\registry.terraform.io\hashicorp\template\2.2.0\windows_amd64\terraform-provider-template_v2.2.0_x4.exe:
Le chemin d’accès spécifié est introuvable.

Error: Failed to install provider

Error while installing hashicorp/random v3.1.0: open
.terraform\providers\registry.terraform.io\hashicorp\random\3.1.0\windows_amd64\terraform-provider-random_v3.1.0_x5.exe:
Le chemin d’accès spécifié est introuvable.

time=2021-03-28T00:17:32+01:00 level=error msg=Hit multiple errors:
Hit multiple errors:
exit status 1

Expected Behavior

check the local path length and in case of exceeding the length throw a custom error message

Actual Behavior

no error is present at the TRACE log , except the below generic exception at the end
Error: Failed to install provider , the specified path is not found

Steps to Reproduce

  1. terraform init
@elhadrio elhadrio added bug new new issue not yet triaged labels Mar 27, 2021
@elhadrio elhadrio changed the title Failed to install provider On Windows Failed to install provider On Windows , PATH MAX LIMIT Mar 27, 2021
@jbardin jbardin added dependencies Auto-pinning windows and removed new new issue not yet triaged labels Mar 29, 2021
@apparentlymart
Copy link
Contributor

Hi @hadri-oussama,

According to the Microsoft documentation Maximum Path Length Limitation, the MAX_PATH limit is on by default but can be disabled in recent versions of Windows 10.

You may therefore be able to work around this for now by enabling the global setting LongPathsEnabled in your system registry, although that does mean that all other applications on your system might also encounter long paths, and older software might not be compatible with those.

That documentation also describes a way for Terraform itself to declare that it supports long paths, by including an application manifest. Including that manifest resource directly inside the terraform.exe file depends on the resolution of golang/go#17835, although there still seems to be some debate there about exactly what behavior Go programs should currently have and what impact the manifest would have. In particular, the related proposal golang/go#44466 was declined on the grounds that it's possible to use separate tools to add a manifest resource to an executable after the Go toolchain has compiled it.

Since our build process is currently standardized across all platforms (using a cross-compiler tool) we are not currently equipped to run custom post-processing steps, such as adding resources, to the executable only on one platform, but it seems like that is what would be required to fully resolve this, and so I'm going to mark this as an enhancement to reflect that we need to do some further design work in order to understand the requirements and implications.

In the meantime, Terraform is subject to the limitations of each platform it runs on and unfortunately on windows MAX_PATH is one of those limitations. Until we're able to prioritize further research on this, I think it'll be necessary to work around it by placing your Terraform working directory at a shallower path on your system, or by setting the TF_DATA_DIR environment variable to force Terraform to place the plugin cache (and other working directory state) in a separate location from the working directory.

Thanks for reporting this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants