azure-pipelines-agent: Agent unable to find location of `pwsh` for PowerShell task - works in Hosted build

Have you tried trouble shooting?

Trouble shooting doc

Yes.

Agent Version and Platform

Version of your agent? v2.141.0

OS of the machine running the agent? Raspbian Linux ARM

VSTS Type and Version

VisualStudio.com or On-Prem TFS? VisualStudio.com

If VisualStudio.com, what is your account name? http://mtntop.visualstudio.com

What’s not working?

Given the following yml definition:

queue:
  name: RaspberryPis
steps:
- script: 'pwsh -c "Write-Host 'Hello World'"' 
  displayName: 'Command Line Script'

- powershell: 'Write-Host "Hello World"' 
  displayName: 'PowerShell Script'

Running on a Raspberry Pi that has PowerShell installed and symlinked to /usr/bin.

The first step passes - it’s able to resolve the pwsh and run it. No problem.

The second step fails with:

Unable to locate executable file: ‘pwsh’. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.

From the logs below it looks like an issue with reading for which.

NOTE: This build passes completely in the hosted vsts linux preview.

Agent and Worker’s Diagnostic Logs

Logs are located in the agent’s _diag folder. The agent logs are prefixed with Agent_ and the worker logs are prefixed with Worker_. All sensitive information should already be masked out, please double check before pasting here.

Diagnostic from Azure Pipelines build run:

2018-10-02T18:46:42.8780796Z ##[debug]Evaluating condition for step: 'PowerShell Script'
2018-10-02T18:46:42.8783690Z ##[debug]Evaluating: succeeded()
2018-10-02T18:46:42.8784925Z ##[debug]Evaluating succeeded:
2018-10-02T18:46:42.8786658Z ##[debug]=> True
2018-10-02T18:46:42.8788476Z ##[debug]Result: True
2018-10-02T18:46:42.8790132Z ##[section]Starting: PowerShell Script
2018-10-02T18:46:42.8808019Z ==============================================================================
2018-10-02T18:46:42.8808922Z Task         : PowerShell
2018-10-02T18:46:42.8809609Z Description  : Run a PowerShell script on Windows, macOS, or Linux.
2018-10-02T18:46:42.8810360Z Version      : 2.136.0
2018-10-02T18:46:42.8811010Z Author       : Microsoft Corporation
2018-10-02T18:46:42.8811721Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkID=613736)
2018-10-02T18:46:42.8812464Z ==============================================================================
2018-10-02T18:46:43.4858352Z ##[debug]agent.workFolder=/home/pi/myagent/_work
2018-10-02T18:46:43.4987737Z ##[debug]loading inputs and endpoints
2018-10-02T18:46:43.5017033Z ##[debug]loading INPUT_TARGETTYPE
2018-10-02T18:46:43.5066356Z ##[debug]loading INPUT_FILEPATH
2018-10-02T18:46:43.5081637Z ##[debug]loading INPUT_SCRIPT
2018-10-02T18:46:43.5090290Z ##[debug]loading INPUT_ERRORACTIONPREFERENCE
2018-10-02T18:46:43.5098646Z ##[debug]loading INPUT_FAILONSTDERR
2018-10-02T18:46:43.5106858Z ##[debug]loading INPUT_IGNORELASTEXITCODE
2018-10-02T18:46:43.5114897Z ##[debug]loading INPUT_WORKINGDIRECTORY
2018-10-02T18:46:43.5123657Z ##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
2018-10-02T18:46:43.5134411Z ##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
2018-10-02T18:46:43.5142618Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
2018-10-02T18:46:43.5157994Z ##[debug]loaded 10
2018-10-02T18:46:43.5270675Z ##[debug]check path : /home/pi/myagent/_work/_tasks/PowerShell_e213ff0f-5d5c-4791-802d-52ea3e7be1f1/2.136.0/task.json
2018-10-02T18:46:43.5281605Z ##[debug]set resource file to: /home/pi/myagent/_work/_tasks/PowerShell_e213ff0f-5d5c-4791-802d-52ea3e7be1f1/2.136.0/task.json
2018-10-02T18:46:43.5285605Z ##[debug]system.culture=en-US
2018-10-02T18:46:43.5383307Z ##[debug]errorActionPreference=stop
2018-10-02T18:46:43.5406967Z ##[debug]failOnStderr=false
2018-10-02T18:46:43.5414964Z ##[debug]ignoreLASTEXITCODE=false
2018-10-02T18:46:43.5428785Z ##[debug]workingDirectory=/home/pi/myagent/_work/1/s
2018-10-02T18:46:43.5431933Z ##[debug]check path : /home/pi/myagent/_work/1/s
2018-10-02T18:46:43.5444314Z ##[debug]targetType=inline
2018-10-02T18:46:43.5455525Z ##[debug]script=Write-Host "Hello World"
2018-10-02T18:46:43.5591033Z Generating script.
2018-10-02T18:46:43.5604411Z ##[debug]Agent.Version=2.141.0
2018-10-02T18:46:43.5606348Z ##[debug]agent.tempDirectory=/home/pi/myagent/_work/_temp
2018-10-02T18:46:43.5609542Z ##[debug]check path : /home/pi/myagent/_work/_temp
2018-10-02T18:46:43.5723544Z ##[debug]which 'pwsh'
2018-10-02T18:46:43.5760756Z ##[debug]not found
2018-10-02T18:46:43.5767110Z ##[debug]which 'powershell'
2018-10-02T18:46:43.5773661Z ##[debug]not found
2018-10-02T18:46:43.5778974Z ##[debug]which 'pwsh'
2018-10-02T18:46:43.5788269Z ##[debug]not found
2018-10-02T18:46:43.5807700Z ##[debug]task result: Failed
2018-10-02T18:46:43.6116303Z ##[error]Unable to locate executable file: 'pwsh'. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.
2018-10-02T18:46:43.6171838Z ##[debug]Processed: ##vso[task.issue type=error;]Unable to locate executable file: 'pwsh'. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.
2018-10-02T18:46:43.6243846Z ##[debug]Processed: ##vso[task.complete result=Failed;]Unable to locate executable file: 'pwsh'. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.
2018-10-02T18:46:43.6251017Z ##[section]Finishing: PowerShell Script

Related Repositories

Please ensure you are logging issues to the correct repository in order to get the best support.

  • Tasks Repository - contains all of the inbox tasks we ship with VSTS/TFS. If you are having issues with tasks in Build/Release jobs (e.g. unreasonable task failure) please log an issue here.
  • Hosted Agent Image Repository - contains the VM image used in the VSTS Hosted Agent Pool. If you are having Build/Release failures that seems like they are related to software installed on the Hosted Agent (e.g. the DotnetSDK is missing or the AzureSDK is not on the latest version) please log an issue here.

If you are hitting a generic issue about VSTS/TFS, please report it to the Developer Community

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 16 (14 by maintainers)

Most upvoted comments

@tylerl0706 thanks for reporting this. It’s interesting that from your script, bash resolves and runs pwsh, but our task fail’s to. I’ll log a bug in the task repo.

Regarding permissions, what Ting said makes sense to me.

@tylerl0706 i guess 755 is better than 777, everyone can use powershell, but they can’t modify the file.