Forum Discussion
Error: spawn C:\hostedtoolcache\windows\terraform\1.5.5\x64\terraform.exe ENOENT
Take this:
- Terraform Not Installed or Not Found
Even if the path seems valid, the agent might not have Terraform installed at that location. If you're using a Microsoft-hosted agent, you need to explicitly install Terraform in your pipeline.
Add a TerraformInstaller task before using Terraform:
- task: TerraformInstaller@0
inputs:
terraformVersion: '1.5.5'
- Incorrect Working Directory
If your pipeline references a working directory that doesn’t match the location of your Terraform files or artifacts, Terraform won’t find main.tf, and the error might misleadingly point to the executable.
Double-check the workingDirectory in your Terraform task. It should match the path where your .tf files are located:
workingDirectory: '$(System.DefaultWorkingDirectory)/_YourArtifactName/drop'
- Artifact Source Alias Mismatch
If you renamed your artifact, make sure the pipeline references the correct alias. A mismatch here can cause the pipeline to look in the wrong place.
Update the workingDirectory to reflect the new artifact name:
workingDirectory: '$(System.DefaultWorkingDirectory)/_RenamedArtifact/drop'