Skip to content

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

Closed

Description

@dlnash18

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

Activity

  1. added
    Needs-Triage
    on Sep 20, 2022
  2. dlnash18 commented on Sep 21, 2022

    @dlnash18
    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
    
  3. added
    Issue-Bug
    WG-DevEx-Portability
    on Sep 26, 2022
  4. microsoft-github-policy-service commented on Nov 15, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  5. microsoft-github-policy-service commented on Nov 15, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  6. added
    Resolution-No Activity
    on Nov 15, 2023
  7. microsoft-github-policy-service commented on Nov 15, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  8. microsoft-github-policy-service commented on Nov 22, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugNeeds-TriageResolution-No ActivityWG-DevEx-Portability

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions