PowerShell commands fail on Linux Agents with "The application to execute does not exist"

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

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
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-21590 - Getting issue details... STATUS BAM-20854 - Getting issue details... STATUS

Solution

We can force the Script Task to use PowerShell through the steps below:

  1. On your Script Task, make sure the Interpreter is set as Shell.
  2. Replace the shebang from your inline/file script with the following:

    #!/usr/bin/env pwsh

That's it!



Last modified on Nov 21, 2022

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.