Skip to content

PowerShell installed as a .NET global tool cannot invoke its own CLI on macOS #12205

@mklement0

Description

@mklement0

When PowerShell is installed as a .NET global tool, it prepends its own $PSHOME folder to $env:PATH.

However, on macOS $PSHOME contains an incompatible pwsh binary that is for Linux.

Therefore, from within an existing session, invoking pwsh (by mere file name) unexpectedly fails.

Steps to reproduce

# Install PowerShell as a .NET global tool, to ~/.dotnet/tools
dotnet tool install powershell -g

# Invoke it, and try to re-invoke its own CLI.
~/.dotnet/tools/pwsh -noprofile -c 'pwsh -noprofile -c write-output hi' | Should -Be 'hi'

Expected behavior

The test should succeed.

Actual behavior

The test fails, due to incompatible binary being invoked:

Expected 'hi', but got @('ResourceUnavailable: Program 'pwsh' failed to run: Exec format errorAt line:1 char:1' ...

Environment data

PowerShell Core v7.0.0 (7.0.0) on macOS 10.15.3

Metadata

Metadata

Labels

Area-Maintainers-Buildspecific to affecting the buildIssue-BugIssue has been identified as a bug in the productResolution-No ActivityIssue has had no activity for 6 months or more

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions