PowerShell commands fail on Linux Agents with "The application to execute does not exist"
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
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:
2022-11-21
1
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 powershell. This is related to the following feature requests:
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:
1
#!/usr/bin/env pwsh
That's it!
Was this helpful?