PowerShell: The application to execute does not exist : '//pwsh.dll'. When running script with shebang from bash with PS v7.3.0 installed
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
Create /tmp/test.ps1 script with shebang using the below code:
#!/usr/bin/pwsh
$true
Set the executable bit with chmod +x /tmp/test.ps1
command and run the script from bash shell on WSL/Linux with PowerShell v7.3.0 installed.
Expected behavior
$ /tmp/test.ps1
True
Actual behavior
$ /tmp/test.ps1
The application to execute does not exist: '/tmp/pwsh.dll'.
Error details
No response
Environment data
Name Value
---- -----
PSVersion 7.3.0
PSEdition Core
GitCommitId 7.3.0
OS Linux 5.15.68.1-microsoft-standard-WSL2 #1 SMP Mon Sep 19 19:14:52 UTC 2022
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visuals
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 8
- Comments: 32 (5 by maintainers)
Commits related to this issue
- https://github.com/PowerShell/PowerShell/issues/18510 — committed to net-utilities/BigIPReport by timriker 2 years ago
- https://github.com/PowerShell/PowerShell/issues/18510 — committed to net-utilities/BigIPReport by timriker a year ago
- Hash rework #36 (#112) * Hash rework #36 * Updating Cypress tests to be compatible with the new direct links * Removing unused constants from Cypress tests * https://github.com/PowerShell/PowerShe... — committed to net-utilities/BigIPReport by timriker a year ago
Ubuntu 20.04 and Ubuntu 22.04, after upgrading to 7.3.0 via apt same error. Found a workaround: #!/usr/bin/env pwsh as shebang
It’s a common (ab)use of the env utility, it decouples the scripts from path prefix.
Just to give full solution, to call it with
-NoProfile
parameter, you need to add-S/--split-string
parameter to env. Working shebang would look like this:The fix for https://github.com/dotnet/runtime/issues/78941 is included in .NET 7.0.3, which was released 2 weeks back. PowerShell v7.3.3 targets .NET 7.0.3, so the fix is in for PowerShell.
The fix to https://github.com/dotnet/runtime/issues/78941 will be backported to .NET 7. Once the new .NET 7.x release is out, we will have a service release to 7.3 to include that .NET fix.
Re-open the issue. .NET will ship the fix in 7.0.3, which is supposed to be out in February. Will close this issue once we ship a servicing release with .NET 7.0.3.
This issue has been marked as external and has not had any activity for 1 day. It has been be closed for housekeeping purposes.
Same here on Ubuntu after upgrade. The script does not start using Shebang and reports missing pwsh.dll It works when I start it with pwsh script.ps1
I deleted the post almost immediately, but you managed to read it. )) I was misled that in powershell-7.3.0-linux-x64.tar.gz pwsh is not executable.
In my environment shebang scripts work.
#!/usr/bin/pwsh -noprofile