Reputation: 9201
What specific configuration or syntax changes must be made in order to resolve the
The system cannot find the path specified.
error that terraform is throwing when it tries to load a provider from a local mirror?
THE PROBLEM
A local file system mirror for terraform providers is re-used in an automation program.
The console prints out The system cannot find the path specified.
during the third use of the same provider by the third module that tries to download the module within 2 minutes.
The first two times the same provider is requested from the same local file system mirror succeed within a couple minutes before this error is thrown.
The problem persists when the calling program sleeps 360 seconds before each request in an attempt to avoid possible locking causes. 6 minute delay does not prevent problem.
THE PROVIDER EXE FILE EXISTS
The terraform-provider-aws_v3.22.0_x5.exe
provider file does indeed appear when we view it in Windows Explorer. Then, we we right click on the exe file and open the properties window, the location and file name are given as:
C:\projects\TERRAF~1\29DEC2~1\TERRAF~2\CALLS-~1\INSTAN~1\SUBNET~1\DEMO-D~1\TERRAF~1\PROVID~1\REGIST~1.IO\HASHIC~1\aws\322~1.0\WINDOW~1
Then when we run a dir
command to explore the directory, we also see the following:
C:\path\to\some\directory>dir C:\projects\TERRAF~1\29DEC2~1\TERRAF~2\CALLS-~1\INSTAN~1\SUBNET~1\DEMO-D~1\TERRAF~1\PROVID~1\REGIST~1.IO\HASHIC~1\aws\322~1.0\WINDOW~1
Volume in drive C is Windows
Volume Serial Number is DAB2-5285
Directory of C:\projects\TERRAF~1\29DEC2~1\TERRAF~2\CALLS-~1\INSTAN~1\SUBNET~1\DEMO-D~1\TERRAF~1\PROVID~1\REGIST~1.IO\HASHIC~1\aws\322~1.0\WINDOW~1
12/29/2020 01:36 PM <DIR> .
12/29/2020 01:36 PM <DIR> ..
12/29/2020 01:36 PM 175,883,264 terraform-provider-aws_v3.22.0_x5.exe
1 File(s) 175,883,264 bytes
2 Dir(s) 736,395,243,520 bytes free
COMPLETE STACK TRACE
The complete TRACE output of the terraform command is as follows:
Initializing provider plugins...
- Finding latest version of hashicorp/aws...
2020/12/29 13:36:35 [TRACE] getproviders.SearchLocalDirectory: C:\path\to\terraform\providers is a symlink to C:\path\to\terraform\providers
2020/12/29 13:36:35 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/hashicorp/aws v3.22.0 for windows_amd64 at C:\path\to\terraform\providers\registry.terraform.io\hashicorp\aws\3.22.0\windows_amd64
2020/12/29 13:36:35 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/hashicorp/http v2.0.0 for windows_amd64 at C:\path\to\terraform\providers\registry.terraform.io\hashicorp\http\2.0.0\windows_amd64
2020/12/29 13:36:35 [TRACE] providercache.Dir.InstallPackage: installing registry.terraform.io/hashicorp/aws v3.22.0 from C:\path\to\terraform\providers\registry.terraform.io\hashicorp\aws\3.22.0\windows_amd64
- Installing hashicorp/aws v3.22.0...
2020/12/29 13:36:35 [TRACE] providercache.fillMetaCache: scanning directory .terraform\providers
2020/12/29 13:36:35 [TRACE] getproviders.SearchLocalDirectory: .terraform\providers is a symlink to .terraform\providers
2020/12/29 13:36:35 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/hashicorp/aws v3.22.0 for windows_amd64 at .terraform\providers\registry.terraform.io\hashicorp\aws\3.22.0\windows_amd64
2020/12/29 13:36:35 [TRACE] providercache.fillMetaCache: error while scanning directory .terraform\providers: cannot search .terraform\providers\registry.terraform.io\hashicorp\aws\3.22.0\windows_amd64\terraform-provider-aws_v3.22.0_x5.exe: CreateFile .terraform\providers\registry.terraform.io\hashicorp\aws\3.22.0\windows_amd64\terraform-provider-aws_v3.22.0_x5.exe: The system cannot find the path specified.
Error: Failed to install provider
@JohnHanley's SUGGESTION
Per @JohnHanley's suggestion in the comments, we reset the `` registry key to 1
and then opened a different instance of Windows CMD, navigated to the same directory, and ran the same automation program.
The program now stops at the same place as before, but this time the program hangs in definitely instead of explicitly throwing an error.
Here is the new console output up to the point where it hangs:
Initializing provider plugins...
- Finding latest version of hashicorp/aws...
2020/12/29 15:39:21 [TRACE] getproviders.SearchLocalDirectory: C:\path\to\terraform\providers is a symlink to C:\path\to\terraform\providers
2020/12/29 15:39:21 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/hashicorp/aws v3.22.0 for windows_amd64 at C:\path\to\terraform\providers\registry.terraform.io\hashicorp\aws\3.22.0\windows_amd64
2020/12/29 15:39:21 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/hashicorp/http v2.0.0 for windows_amd64 at C:\path\to\terraform\providers\registry.terraform.io\hashicorp\http\2.0.0\windows_amd64
2020/12/29 15:39:21 [TRACE] providercache.Dir.InstallPackage: installing registry.terraform.io/hashicorp/aws v3.22.0 from C:\path\to\terraform\providers\registry.terraform.io\hashicorp\aws\3.22.0\windows_amd64
- Installing hashicorp/aws v3.22.0...
Upvotes: 1
Views: 10556
Reputation: 81454
The error messages indicate a MAX_PATH problem. A side issue is that the path is using the DOS namespace. The solution is to either reorganize the directory structure to shorten the path or use UNC Paths.
For the DOS namespace, applications are often coded to support a maximum length of 255 characters. For the LONG namespace the maximum length is 260 characters of which the directory portion cannot exceed MAX_PATH - 12 (248) characters. The terminating NULL consumes one character.
Enable Long Paths in Windows 10, Version 1607, and Later
Upvotes: 3