##[error]Error: There was an error when attempting to execute the process ‘C:\hostedtoolcache\windows\terraform\1.7.2\x64\terraform.exe’. This may indicate the process failed to start. Error: spawn C:\hostedtoolcache\windows\terraform\1.7.2\x64\terraform.exe ENOENT
Hi @rine184
The ENOENT error is often associated with no such file or directory. Check on your pipeline task that you have your working directory set correctly (usually set to the path to the root module you are working with), paths to exe are correct, etc.
If you don’t spot anything there and still have the problem we’ll need a little more information:
Are you using an MS hosted or self hosted pipeline agent?
What is the ADO Pipeline task you are using, and what are you doing with it (init/plan/apply)?
Can you share the YAML of the task from your pipeline?
What is the path to the module root you are working with (eg /terraform)?
This is likely more an Azure Devops Pipeline issue than a Terraform issue.
Hi, Thank you for your reply.
Please find the response below.
Are you using an MS hosted or self hosted pipeline agent? MS hosted Windows-latest)
What is the ADO Pipeline task you are using, and what are you doing with it (init/plan/apply)? Yes
Can you share the YAML of the task from your pipeline? Please find below.
What is the path to the module root you are working with (eg /terraform)? Azure Repo (landing_zone/001_resource_groups)
parameters:
terraformVersion:
serviceConnectionName:
projectDirectory:
environmentName:
tfBackendResourceGroup:
tfBackendStorageAccountName:
tfBackendContainerName:
tfBackendContainerKey:
tfVarFile:
jobs:
- job: Validate
steps:-
checkout: self
path: src -
task: TerraformInstaller@1
displayName: "Terraform Install Version {{ parameters.terraformVersion }}" inputs: terraformVersion: {{ parameters.terraformVersion }} -
task: TerraformTaskV4@4
displayName: “Terraform Init”
inputs:
provider: “azurerm”
command: “init”
workingDirectory: “(Agent.BuildDirectory)/src/{{ parameters.projectDirectory }}/”
backendServiceArm: {{ parameters.serviceConnectionName }} backendAzureRmResourceGroupName: {{ parameters.tfBackendResourceGroup }}
backendAzureRmStorageAccountName: {{ parameters.tfBackendStorageAccountName }} backendAzureRmContainerName: {{ parameters.tfBackendContainerName }}
backendAzureRmKey: ${{ parameters.tfBackendContainerKey }}
retryCountOnTaskFailure: 3
-
Thanks @rine184 - Which task is failing. You’ve posted the entire pipeline (which is helpful) so I can see you are most likely using the following extension in your pipeline, but you’ve not indicated which of the tasks is throwing the error and halting the pipeline. Is it the Powershell@2 Terraform Fmt check or one of the later TerraformTaskV4@4
Please confirm this is the extention you are using: Microsoft Devlabs Terraform extension
Also, for the failing task, if you run the pipeline with diagnostics, do you get some further information and details of the paths that are actually being substituted for the variables that you have in the above
Thanks
its the “Terraform Init” task which is failing with the error ENONT.
yes, I have installed the same extension for ADO.
with the diagnostics, its the same error details are showing.
Thanks
It definitely looks like this is an issue around the pipeline and the task as opposed to a Terraform issue. There have been a couple of people reporting similar issues against the Devops Extension here that appear to be related to YAML/formatting:
You will probably get more specific assistance by posting an issue there and by reviewing that thread where some have resolved the issue by rebuilding their pipeline.
Although I am unfamiliar with this specific extension I did create a basic pipeline from scratch using the install and init task with no issues.
One element of logging that you may want to check and confirm in the INIT task (with diagnostic set) is a block similar to the following, where the init task detects the version of Terraform and it’s location
##[debug]provider=azurerm
##[debug]command=init
##[debug]workingDirectory=D:\a\1\s\terraform
##[debug]commandOptions=undefined
##[debug]which 'terraform'
##[debug]found: 'C:\hostedtoolcache\windows\terraform\1.7.2\x64\terraform.exe'
##[debug]which 'C:\hostedtoolcache\windows\terraform\1.7.2\x64\terraform.exe'
##[debug]found: 'C:\hostedtoolcache\windows\terraform\1.7.2\x64\terraform.exe'
##[debug]C:\hostedtoolcache\windows\terraform\1.7.2\x64\terraform.exe arg: init
And also validate the actual command line that will be run (this should appear in the logs)
C:\hostedtoolcache\windows\terraform\1.7.2\x64\terraform.exe init -backend-config=storage_account_name=tfstate******* -backend-config=container_name=tfstate -backend-config=key=abcd1234 -backend-config=resource_group_name=rg-tfstate -backend-config=subscription_id=***-dce8-4706-8ba9-32036d226ec1 -backend-config=tenant_id=***-932f-43f9-80f1-8c6382f057bb -backend-config=client_id=*** -backend-config=client_secret=***
Sorry, I can’t really assist you much more on this one - it appears specific to that Devops Extension which I have not used previously.
I’ve also a error message attempting to execute Terraform processes. The error, titled “Error: There was an error when attempting to execute the process”, followed by “ENOENT”, indicates a failure to start the ‘terraform.exe’ executable. I’m unable to resolve the issue. This error has halted my workflow and left me seeking assistance for potential solutions or insights.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.