microsoft / PowerToys

Windows system utilities to maximize productivity
MIT License
111.44k stars 6.56k forks source link

Exception on opening Powershell 7.4.2 with #33304

Open M0ST4FA opened 5 months ago

M0ST4FA commented 5 months ago

Microsoft PowerToys version

0.81.1

Installation method

WinGet

Running as admin

No

Area(s) with issue?

Command not found

Steps to reproduce

Just open Powershell with Command not found already set up.

✔️ Expected Behavior

Powershell to open without any error.

❌ Actual Behavior

You get an error that says this: Unhandled exception. System.Management.Automation.CmdletInvocationException: An error occurred while connecting to the catalog. ---> Microsoft.WinGet.Client.Engine.Exceptions.CatalogConnectException: An error occurred while connecting to the catalog. at Microsoft.WinGet.Client.Engine.Commands.Common.FinderCommand.GetPackageCatalog(CompositeSearchBehavior behavior) at Microsoft.WinGet.Client.Engine.Commands.Common.FinderCommand.FindPackages(CompositeSearchBehavior behavior, UInt32 limit, PackageFieldMatchOption match) at Microsoft.WinGet.Client.Engine.Commands.Common.FinderExtendedCommand.FindPackages(CompositeSearchBehavior behavior, PackageFieldMatchOption match) at Microsoft.WinGet.Client.Engine.Commands.FinderPackageCommand.<>c__DisplayClass1_0.b0() at Microsoft.WinGet.Client.Engine.Commands.Common.ManagementDeploymentCommand.Execute[TResult](Func1 func) at Microsoft.WinGet.Client.Engine.Commands.FinderPackageCommand.Find(String psPackageFieldMatchOption) at Microsoft.WinGet.Client.Commands.FindPackageCmdlet.ProcessRecord() at System.Management.Automation.CommandProcessor.ProcessRecord() --- End of inner exception stack trace --- at System.Management.Automation.Runspaces.AsyncResult.EndInvoke() at System.Management.Automation.PowerShell.EndInvoke(IAsyncResult asyncResult) at System.Threading.Tasks.TaskFactory1.FromAsyncCoreLogic(IAsyncResult iar, Func2 endFunction, Action1 endAction, Task`1 promise, Boolean requiresSynchronization) --- End of stack trace from previous location --- at Microsoft.WinGet.CommandNotFound.WinGetCommandNotFoundFeedbackPredictor.WarmUp() at System.Threading.Tasks.Task.<>c.b128_1(Object state) at System.Threading.QueueUserWorkItemCallback.Execute() at System.Threading.ThreadPoolWorkQueue.Dispatch() at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()

Furthermore, the pwsh process aborts a while after this (typical behavior when there is an unhandled exception, I think)

Other Software

No response

ayaen commented 5 months ago

I have the Powertoys winget.commandnotfound module enabled which adds a line to the powershell profile. Now when I try and open pwsh.exe with the default $PROFILE without an internet connection I get the above exception but when I comment out the said line added by PowerToys to my profile, pwsh.exe is back to normal with $PROFILE. So, I am sure it's being caused by the line given below:

some-uuid-xxxx-xxxx powertoys commandnotfound module

Import-Module -name microsoft.winget.commandnotfound -ErrorAction Stop

some-uuid-xxxx-xxxx

If you haven't enabled this module in PowerToys though, I have no clue what else could be causing it.

ayaen commented 5 months ago

They probably need to add some exception handling so that the pwsh process itself doesnt exit, since it doesn't make any sense for the entire shell instance to exit with error just because a minor feature is not up

CodeZhangBorui commented 5 months ago

Same.

Trying to enter a non-existent command when there is no network connection, PowerShell (7.4.2) exits and prints:

An error has occurred that was not properly handled. Additional information is shown below. The PowerShell process will exit.
Unhandled exception. System.Management.Automation.CmdletInvocationException: An error occurred while connecting to the catalog.
 ---> Microsoft.WinGet.Client.Engine.Exceptions.CatalogConnectException: An error occurred while connecting to the catalog.
   at Microsoft.WinGet.Client.Engine.Commands.Common.FinderCommand.GetPackageCatalog(CompositeSearchBehavior behavior)
   at Microsoft.WinGet.Client.Engine.Commands.Common.FinderCommand.FindPackages(CompositeSearchBehavior behavior, UInt32 limit, PackageFieldMatchOption match)
   at Microsoft.WinGet.Client.Engine.Commands.Common.FinderExtendedCommand.FindPackages(CompositeSearchBehavior behavior, PackageFieldMatchOption match)
   at Microsoft.WinGet.Client.Engine.Commands.FinderPackageCommand.<>c__DisplayClass1_0.<Find>b__0()
   at Microsoft.WinGet.Client.Engine.Commands.Common.ManagementDeploymentCommand.Execute[TResult](Func`1 func)
   at Microsoft.WinGet.Client.Engine.Commands.FinderPackageCommand.Find(String psPackageFieldMatchOption)
   at Microsoft.WinGet.Client.Commands.FindPackageCmdlet.ProcessRecord()
   at System.Management.Automation.CommandProcessor.ProcessRecord()
   --- End of inner exception stack trace ---
   at System.Management.Automation.Runspaces.AsyncResult.EndInvoke()
   at System.Management.Automation.PowerShell.EndInvoke(IAsyncResult asyncResult)
   at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- End of stack trace from previous location ---
   at Microsoft.WinGet.CommandNotFound.WinGetCommandNotFoundFeedbackPredictor.WarmUp()
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_1(Object state)
   at System.Threading.QueueUserWorkItemCallback.Execute()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
zkaip commented 5 months ago

Something wrong! This errror is happened sometimes.

PowerShell 7.4.2

An error has occurred that was not properly handled. Additional information is shown below. The PowerShell process will exit.
Unhandled exception. System.Management.Automation.CmdletInvocationException: An error occurred while connecting to the catalog.
 ---> Microsoft.WinGet.Client.Engine.Exceptions.CatalogConnectException: An error occurred while connecting to the catalog.
   at Microsoft.WinGet.Client.Engine.Commands.Common.FinderCommand.GetPackageCatalog(CompositeSearchBehavior behavior)
   at Microsoft.WinGet.Client.Engine.Commands.Common.FinderCommand.FindPackages(CompositeSearchBehavior behavior, UInt32 limit, PackageFieldMatchOption match)
   at Microsoft.WinGet.Client.Engine.Commands.Common.FinderExtendedCommand.FindPackages(CompositeSearchBehavior behavior, PackageFieldMatchOption match)
   at Microsoft.WinGet.Client.Engine.Commands.FinderPackageCommand.<>c__DisplayClass1_0.<Find>b__0()
   at Microsoft.WinGet.Client.Engine.Commands.Common.ManagementDeploymentCommand.Execute[TResult](Func`1 func)
   at Microsoft.WinGet.Client.Engine.Commands.FinderPackageCommand.Find(String psPackageFieldMatchOption)
   at Microsoft.WinGet.Client.Commands.FindPackageCmdlet.ProcessRecord()
   at System.Management.Automation.CommandProcessor.ProcessRecord()
   --- End of inner exception stack trace ---
   at System.Management.Automation.Runspaces.AsyncResult.EndInvoke()
   at System.Management.Automation.PowerShell.EndInvoke(IAsyncResult asyncResult)
   at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- End of stack trace from previous location ---
   at Microsoft.WinGet.CommandNotFound.WinGetCommandNotFoundFeedbackPredictor.WarmUp()
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_1(Object state)
   at System.Threading.QueueUserWorkItemCallback.Execute()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
dousx-coder commented 5 months ago

image PowerShell 7.4.3 Loading personal and system profiles took 827ms. ➜ dousx  ~  63%  Wednesday 13:39:57  0s ⚡ An error has occurred that was not properly handled. Additional information is shown below. The PowerShell process will exit. Unhandled exception. System.Management.Automation.CmdletInvocationException: An error occurred while connecting to the catalog. ---> Microsoft.WinGet.Client.Engine.Exceptions.CatalogConnectException: An error occurred while connecting to the catalog. at Microsoft.WinGet.Client.Engine.Commands.Common.FinderCommand.GetPackageCatalog(CompositeSearchBehavior behavior) at Microsoft.WinGet.Client.Engine.Commands.Common.FinderCommand.FindPackages(CompositeSearchBehavior behavior, UInt32 limit, PackageFieldMatchOption match) at Microsoft.WinGet.Client.Engine.Commands.Common.FinderExtendedCommand.FindPackages(CompositeSearchBehavior behavior, PackageFieldMatchOption match) at Microsoft.WinGet.Client.Engine.Commands.FinderPackageCommand.<>c__DisplayClass1_0.b0() at Microsoft.WinGet.Client.Engine.Commands.Common.ManagementDeploymentCommand.Execute[TResult](Func1 func) at Microsoft.WinGet.Client.Engine.Commands.FinderPackageCommand.Find(String psPackageFieldMatchOption) at Microsoft.WinGet.Client.Commands.FindPackageCmdlet.ProcessRecord() at System.Management.Automation.CommandProcessor.ProcessRecord() --- End of inner exception stack trace --- at System.Management.Automation.Runspaces.AsyncResult.EndInvoke() at System.Management.Automation.PowerShell.EndInvoke(IAsyncResult asyncResult) at System.Threading.Tasks.TaskFactory1.FromAsyncCoreLogic(IAsyncResult iar, Func2 endFunction, Action1 endAction, Task`1 promise, Boolean requiresSynchronization) --- End of stack trace from previous location --- at Microsoft.WinGet.CommandNotFound.WinGetCommandNotFoundFeedbackPredictor.WarmUp() at System.Threading.Tasks.Task.<>c.b128_1(Object state) at System.Threading.QueueUserWorkItemCallback.Execute() at System.Threading.ThreadPoolWorkQueue.Dispatch() at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()

[已退出进程,代码为 3762504530 (0xe0434352)] 现在可以使用Ctrl+D关闭此终端,或按 Enter 重新启动。

hsbt commented 4 months ago

FYI: https://github.com/microsoft/winget-command-not-found/issues/7#issuecomment-2153475740

NaroZeol commented 4 months ago

Same issue when there is no network connection, I have to uninstall "Command Not Found" until this problem is solved.

oldium commented 3 months ago

There is new release of Command not Found to address the exception: https://github.com/microsoft/winget-command-not-found/releases/tag/v1.0.3

walker93 commented 1 week ago

I have the same problem. The error shows up as soon as I open Powershell 7 with the "command not found" feature enabled. I have internet connection so I don't believe that's the problem. Recently I installed Visual Studio 2022 Community Edition that may have changed something on the NuGet side, but I'm not sure.