gerardog/gsudo

Issue: Unhandled Exception when using gsudo on Powershell 7.3.6

cartifanwlr opened this issue · 4 comments

Issue Description

Running gsudo (or with the sudo alias) will return an Unhandled Exception on Powershell 7.3.6. This issue does not happen on Command Prompt or Windows Powershell.

Steps to Reproduce

  1. Open Powershell (pwsh)
  2. Elevate a command with gsudo
  3. Observe the bug.

Screenshots

image
image

Context:

  • Windows version: Windows 11 version 23H2 (Beta Channel) build 22631.2115

I have Win11 22H2 (22000.2176) and Pwsh 7.3.6 (also tested PowerShell preview 7.4.0-preview 4) and I couldn't reproduce the problem.

Please try the following:

Elevate without gsudo.

  • Right click on the Powershell icon and select Run as Administrator. If this throws an error too, then either your installation is corrupt or there is a bug in PowerShell.
  • Right click on Command Prompt, select Run as Administrator, then type PWSH and press enter. If this fails, then the same, the problem is not caused by gsudo.

You can work around the problem by installing Powershell using any method except Microsoft Store:

Apps installed using the MsStore do a very special treatment with security tokens that is hardcoded into windows.
gsudo does a few tricks to workaround this, but apparently doesn't solves all issues.
If you open your Microsoft store and uninstall Powershell, and later install Powershell with a different mechanism,

Alternatively we may want to try to identify the root cause of the problem, but so far I tried traces and I couldn't fix the problem....

This issue is indeed caused by the Microsoft Store version of Powershell. I reinstalled with Winget and gsudo now works fine.

That's great! Can you please let me know if you were able to reproduce the error elevating without gsudo? Or you just installed using winget before trying that? Thank you

That's great! Can you please let me know if you were able to reproduce the error elevating without gsudo? Or you just installed using winget before trying that? Thank you

Elevating without gsudo did indeed work.