title: Terraform The system cannot find the path specified
body: <blockquote>
  <p><strong>What specific configuration or syntax changes must be made in order to resolve the <code>The system cannot find the path specified.</code> error that terraform is throwing when it tries to load a provider from a local mirror?</strong></p>
  </blockquote>
  <p><strong>THE PROBLEM</strong></p>
  <p>A local file system mirror for terraform providers is re-used in an automation program.</p>
  <ol>
  <li><p>The console prints out <code>The system cannot find the path specified.</code> during the third use of the same provider by the third module that tries to download the module within 2 minutes.</p>
  </li>
  <li><p>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.</p>
  </li>
  <li><p>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.</p>
  </li>
  </ol>
  <p><strong>THE PROVIDER EXE FILE EXISTS</strong></p>
  <p>The <code>terraform-provider-aws_v3.22.0_x5.exe</code> 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:</p>
  <pre><code>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  
  </code></pre>
  <p>Then when we run a <code>dir</code> command to explore the directory, we also see the following:</p>
  <pre><code>C:\path\to\some\directory&gt;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    &lt;DIR&gt;          .
  12/29/2020  01:36 PM    &lt;DIR&gt;          ..
  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
  </code></pre>
  <p><strong>COMPLETE STACK TRACE</strong></p>
  <p>The complete TRACE output of the terraform command is as follows:</p>
  <pre><code>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
  </code></pre>
  <p><strong>@JohnHanley's SUGGESTION</strong></p>
  <p>Per @JohnHanley's suggestion in the comments, we reset the `` registry key to <code>1</code> and then opened a different instance of Windows CMD, navigated to the same directory, and ran the same automation program.</p>
  <p>The program now stops at the same place as before, but this time the program hangs in definitely instead of explicitly throwing an error.</p>
  <p>Here is the new console output up to the point where it hangs:</p>
  <pre><code>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...
  </code></pre>