PowerShell commands fail on Linux Agents with "The application to execute does not exist"
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the server and data center platforms.
Summary
A Script Task calls PowerShell but fails to execute with a "The application to execute does not exist" error.
Environment
- Remote agent running on a Linux machine.
- Script Task running PowerShell commands.
Diagnosis
The build throws the following error:
21-Nov-2022 15:11:03 The application to execute does not exist: '/var/atlassian/application-data/bamboo/temp/pwsh.dll'.
Cause
The Script Task does not support running Windows Powershell commands on Linux. In addition to that, the most recent versions of Powershell use pwsh as executables, while the older ones used powerhsell. This is related to the following feature requests:
- BAM-21590Getting issue details... STATUS - BAM-20854Getting issue details... STATUS
Solution
We can force the Script Task to use PowerShell through the steps below:
- On your Script Task, make sure the Interpreter is set as Shell.
Replace the shebang from your inline/file script with the following:
#!/usr/bin/env pwsh
That's it!