This morning when I got to work and turned on my computer, I was shocked: PowerShell would not open. As a result, the development environment I had configured in psmux could not start. Without psmux, I wouldn’t even know how to start my debugging environment… My PowerShell version is 7.6.6.
PowerShell Error
It throws an error as soon as I open it. I restarted the system and logged in again, but it still errors:
totalwidth (‘-17’) must be a non-negative value. (parameter ‘totalwidth’)
The specific error is:
PowerShell 7.6.6
Process terminated.
totalWidth ('-17') must be a non-negative value. (Parameter 'totalWidth')
Actual value was -10.
at System.Environment.FailFast(System.Runtime.CompilerServices.StackCrawlMarkHandle, System.String, System.Runtime.CompilerServices.ObjectHandleOnStack, System.String)
at System.Environment.FailFast(System.Threading.StackCrawlMark ByRef, System.String, System.Exception, System.String)
at System.Environment.FailFast(System.String, System.Exception)
at Microsoft.PowerShell.UnmanagedPSEntry.Start(System.String[], Int32)
at Microsoft.PowerShell.ManagedPSEntry.Main(System.String[])
System.ArgumentOutOfRangeException: totalWidth ('-10') must be a non-negative value. (Parameter 'totalWidth')
Actual value was -10.
at System.ArgumentOutOfRangeException.ThrowNegative[T](T value, String paramName)
at System.String.PadRight(Int32 totalWidth, Char paddingChar)
at Microsoft.PowerShell.UpdatesNotification.ShowUpdateNotification(PSHostUserInterface hostUI)
at Microsoft.PowerShell.ConsoleHost.Start(String bannerText, String helpText, Boolean issProvidedExternally)
at Microsoft.PowerShell.UnmanagedPSEntry.Start(String[] args, Int32 argc)
At first I thought it was caused by dual monitors. I switched between different screens and maximized on each screen, but it still didn’t work. I was completely out of options. Fortunately, I found a solution on GitHub. And it was a discussion from just the past couple of days.
https://github.com/PowerShell/PowerShell/issues/28131
Solution
Launch the Windows command line, i.e., the cmd command line, and enter the following command:
setx POWERSHELL_UPDATECHECK Off
This command disables PowerShell’s update check.
After executing it, close the terminal and reopen PowerShell, and it works normally… I never expected Microsoft could ship such a terrifying bug.
What Is the Root Cause?
I skimmed the discussion in that GitHub issue. It seems the problem occurred in Chinese, Japanese, and Korean. Then a programmer on the development team was still replying an hour ago:
The PowerShell team has decided to remove the Update Notification feature as it provides increasingly limited additional value nowadays.
Truly speechless.