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

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

Open
mklement0 opened this issue Mar 25, 2020 · 2 comments
Open

Comments

@mklement0
Copy link
Contributor

@mklement0 mklement0 commented Mar 25, 2020

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 a 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
@mklement0

This comment was marked as resolved.

Copy link
Contributor Author

@mklement0 mklement0 commented Mar 26, 2020

Thanks for labeling, @SteveL-MSFT; please note that this problem will likely only affect people who use the .NET global tool version interactively.

The likelier use is for CI (automation), and for that #11747 is the much more serious bug (as yet not classified as a bug): something primarily used as a CLI not handling argument parsing properly is highly problematic.

#12176 too is unequivocally a not-yet-classified-as-such bug, though less impactful.

@TravisEz13

This comment has been minimized.

Copy link
Member

@TravisEz13 TravisEz13 commented Apr 7, 2020

I verified this behavior on 7.0.0 on macOS 10.15.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.