Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start-Job fails on macOS when pwsh is installed as a global tool #18139

Open
5 tasks done
dlnash18 opened this issue Sep 20, 2022 · 1 comment
Open
5 tasks done

Start-Job fails on macOS when pwsh is installed as a global tool #18139

dlnash18 opened this issue Sep 20, 2022 · 1 comment
Labels
Issue-Bug Issue has been identified as a bug in the product Needs-Triage The issue is new and needs to be triaged by a work group. WG-DevEx-Portability authoring cross-platform or cross-architecture modules, cmdlets, and scripts

Comments

@dlnash18
Copy link

Prerequisites

Steps to reproduce

I installed the .NET 6.0.401 on macOS 12.6 x86, then installed PowerShell 7.2.6 as a global tool. Using Start-Job results in a failed job. The problem is that ~/.dotnet/tools/.store/powershell/7.2.6/powershell/7.2.6/tools/net6.0/any/unix/pwsh is a Linux ELF executable, not Mach-O. If I move ~/.dotnet/tools/.store/powershell/7.2.6/powershell/7.2.6/tools/net6.0/any/unix/pwsh out of the way and replace it with a symlink to ~/.dotnet/tools/pwsh, then Start-Job works as expected.

I noticed that ~/.dotnet/tools/.store/powershell/7.2.6/powershell/7.2.6/tools/net6.0/any/unix gets prepended to $Env:PATH when pwsh starts up, so the pwsh in that location is the first one found in a path search. I tried altering my path to remove that directory, but Start-Job still uses the pwsh in that location. Only replacing the ELF binary with a link to the Mach-O binary fixes the problem, although I don't know if this might result in other issues (I haven't run into any yet).

Expected behavior

PS> Start-Job -ScriptBlock {}
Id  Name  PSJobTypeName  State    HasMoreData  Location   Command
--  ----  -------------  -----    -----------  --------   -------
1   Job1  BackgroundJob  Running  True         localhost

PS> Get-Job
Id  Name  PSJobTypeName  State      HasMoreData  Location   Command
--  ----  -------------  -----      -----------  --------   -------
1   Job1  BackgroundJob  Completed  False        localhost

Actual behavior

PS> Start-Job -ScriptBlock {}
Id  Name  PSJobTypeName  State   HasMoreData  Location   Command
--  ----  -------------  -----   -----------  --------   -------
1   Job1  BackgroundJob  Failed  False        localhost  

PS> Receive-Job 1
OpenError: [localhost] An error occurred while starting the background process. Error reported: An error occurred trying to start process '/Users/dlnash/.dotnet/tools/.store/powershell/7.2.6/powershell/7.2.6/tools/net6.0/any/unix/pwsh' with working directory '/Users/dlnash'. Exec format error.

PS> cd ~/.dotnet/tools/.store/powershell/7.2.6/powershell/7.2.6/tools/net6.0/any/unix
PS> file pwsh
pwsh: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=8a0b623bb0e55e510d8c7fc1f38184ce019bb0d3, for GNU/Linux 2.6.32, stripped

Error details

No response

Environment data

Name                           Value
----                           -----
PSVersion                      7.2.6
PSEdition                      Core
GitCommitId                    7.2.6
OS                             Darwin 21.6.0 Darwin Kernel Version 21.6.0: Mon Aug 22 20:17:10 PDT…
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

@dlnash18 dlnash18 added the Needs-Triage The issue is new and needs to be triaged by a work group. label Sep 20, 2022
@dlnash18
Copy link
Author

I suppose I should have included this in the actual behavior as well:

PS> cd ~/.dotnet/tools
PS> file pwsh                                        
pwsh: Mach-O 64-bit executable x86_64

@StevenBucher98 StevenBucher98 added Issue-Bug Issue has been identified as a bug in the product WG-DevEx-Portability authoring cross-platform or cross-architecture modules, cmdlets, and scripts labels Sep 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug Issue has been identified as a bug in the product Needs-Triage The issue is new and needs to be triaged by a work group. WG-DevEx-Portability authoring cross-platform or cross-architecture modules, cmdlets, and scripts
Projects
None yet
Development

No branches or pull requests

2 participants