Azure Pipelines "<tool>: command not found" on the agent
A bash or script step called a binary the agent could not find. Either the tool is not installed on the image, or it was installed in a way that did not put it on the PATH for this step.
What this error means
A script step fails with <tool>: command not found and ##[error]Bash exited with code '127', the conventional code for a missing command.
/home/vsts/work/_temp/script.sh: line 1: terraform: command not found
##[error]Bash exited with code '127'.Common causes
The tool is not on the agent image
The CLI is not preinstalled on the hosted or self-hosted image, so the shell cannot find it.
Installed but not on PATH for this step
A tool installed in one step is not on PATH in a later step, because each step starts a fresh shell and PATH changes do not persist unless exported through a logging command.
How to fix it
Install the tool with its setup task
Use the dedicated installer task (or a script) before the step that needs the tool, so it is present and on PATH.
- task: TerraformInstaller@1
inputs:
terraformVersion: 'latest'
- script: terraform version
displayName: 'Verify terraform'Persist a custom PATH across steps
If you install into a custom directory, prepend it to PATH for later steps with a logging command.
- bash: echo "##vso[task.prependpath]$HOME/bin"
displayName: 'Add ~/bin to PATH'How to prevent it
- Install required tools with a setup task before they are used.
- Use
task.prependpathto persist custom PATH entries across steps. - Check the hosted image software list for preinstalled tools.