microsoft / terminal

The new Windows Terminal and the original Windows console host, all in the same place!
MIT License
94.88k stars 8.22k forks source link

Suddenly unable to launch PowerShell in Windows Terminal via Run/shell #16660

Closed ninbura closed 7 months ago

ninbura commented 7 months ago

Windows Terminal version

1.19.10292.0

Windows build number

10.0.22631.0

Other Software

PowerShell 7 - v7.4.1 PowerShell - v5.1.22621.2506

Steps to reproduce

via run

  1. open Run
  2. input wt pwsh
  3. click "OK"

via shell

  1. open PowerShell, PowerShell 7, or Command Prompt
  2. input wt pwsh or wt PowerShell

nuance

For whatever reason I've found that it is sometimes necessary to run wt [shell] more than once before Windows Terminal will even launch to print the error message. Almost as if Terminal itself is hard crashing before it can display.

Expected Behavior

  1. wt pwsh launches Windows Terminal with the PowerShell 7 profile without error.
  2. wt PowerShell launches Windows Terminal with the PowerShell profile without error.

Actual Behavior

  1. wt pwsh launches Windows Terminal with the PowerShell 7 profile and displays the following error & exit code:
    • Process terminated. The type initializer for 'System.Management.Automation.Runspaces.InitialSessionState' threw an exception.
       at System.Environment.FailFast(System.String, System.Exception)
       at Microsoft.PowerShell.UnmanagedPSEntry.Start(System.String[], Int32)
       at Microsoft.PowerShell.ManagedPSEntry.Main(System.String[])
      System.TypeInitializationException: The type initializer for 'System.Management.Automation.Runspaces.InitialSessionState' threw an exception.
      ---> System.ComponentModel.Win32Exception (126): The specified module could not be found.
       at System.Management.Automation.Internal.SecuritySupport.GetSaferPolicy(String path, SafeHandle handle)
       at System.Management.Automation.Security.SystemPolicy.TestSaferPolicy(String testPathScript, String testPathModule)
       at System.Management.Automation.Security.SystemPolicy.GetAppLockerPolicy(String path, SafeHandle handle)
       at System.Management.Automation.Security.SystemPolicy.GetLockdownPolicy(String path, SafeHandle handle)
       at System.Management.Automation.Security.SystemPolicy.GetSystemLockdownPolicy()
       at System.Management.Automation.Runspaces.InitialSessionState..cctor()
       --- End of inner exception stack trace ---
       at System.Management.Automation.Runspaces.InitialSessionState.CreateDefault2()
       at Microsoft.PowerShell.UnmanagedPSEntry.Start(String[] args, Int32 argc)
      [process exited with code 2148734499 (0x80131623)]
      You can now close this terminal with Ctrl+D, or press Enter to restart.
  2. wt PowerShell launches Windows Terminal with the PowerShell profile and displays the following error & exit code:

    • Internal Windows PowerShell error.  Loading managed Windows PowerShell failed with error 8009001d.
      
      [process exited with code 4294901760 (0xffff0000)]
      You can now close this terminal with Ctrl+D, or press Enter to restart.
github-actions[bot] commented 7 months ago

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

ninbura commented 7 months ago

more details

From what I can tell, this started to occur after updating Windows Terminal to version 1.19.10292.0. The issue is replicable on 3 systems that I own, all on different chipsets, but running the same Windows Edition, Version, & OS Build.

  1. Windows Edition - Windows 11 Pro N for Workstations
  2. Windows Version - 23H2
  3. Windows OS Build - 22631.3085

There is another issue on the PowerShell repository (https://github.com/PowerShell/PowerShell/issues/20595) that mentions this same error, but it has been closed as it was mentioned to be an issue with Windows terminal; linking to this https://github.com/microsoft/terminal/issues/16051. Which has been locked due to participant's "spicy" behavior. However, I'm not sure I have the same issue as running the Get-EnvsWithEmbeddedNull script mentioned in https://github.com/microsoft/terminal/issues/16051 does not list any corrupt registry entries on any of my 3 systems.

things I've tried

  1. restarting my systems
  2. checking for updates
  3. un-installing & re-installing Windows Terminal via winget
  4. Running the Get-EnvsWithEmbeddedNull script script, as mentioned before.
  5. manually searching registry locations in regedit
PiTomar commented 7 months ago

I guess this is a bug in the v1.19 Release and will be probably fixed in v1.20. See: https://github.com/microsoft/terminal/releases/tag/v1.20.10303.0

zadjii-msft commented 7 months ago

Yea pretty sure this is /dup #16623, which is already fixed in v1.19.10302.0

microsoft-github-policy-service[bot] commented 7 months ago

Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!