PowerToys icon indicating copy to clipboard operation
PowerToys copied to clipboard

[PTRun]Crash on Settings update at startup after updating PowerToys

Open ssaari opened this issue 1 year ago • 12 comments

Microsoft PowerToys version

0.74.0

Installation method

PowerToys auto-update

Running as admin

No

Area(s) with issue?

General

Steps to reproduce

Clicked to approve update from the PowerToys update available prompt. 2023-09-27.txt

✔️ Expected Behavior

installation success

❌ Actual Behavior

"Something went wrong" popup with log displayed. Log file is attached. Exception: System.UnauthorizedAccessException: Access to the path 'C:\Users\ssaari\AppData\Local\Microsoft\PowerToys\PowerToys Run\Settings\Plugins\Microsoft.Plugin.Shell\ShellPluginSettings.json' is denied.

However I restarted the program and it shows version 0.74.0.0. I do not know what the previous version was that was installed, but I never skip updates.

Other Software

No response

ssaari avatar Sep 27 '23 14:09 ssaari

"C:\Users\ssaari\AppData\Local\Microsoft\PowerToys\PowerToys Run\Settings\Plugins\Microsoft.Plugin.Shell\ShellPluginSettings.json"

Is this a file you can access if you go there through File Explorer, for example? The error seems to be about access to that file. /needinfo

jaimecbernardo avatar Sep 27 '23 15:09 jaimecbernardo

Yes, I opened the file that I attached.

Regards,

Scott Saari @.*** 602-230-7824

On Wed, Sep 27, 2023 at 9:34 AM Jaime Bernardo @.***> wrote:

"C:\Users\ssaari\AppData\Local\Microsoft\PowerToys\PowerToys Run\Settings\Plugins\Microsoft.Plugin.Shell\ShellPluginSettings.json"

Is this a file you can access if you go there through File Explorer, for example? The error seems to be about access to that file. /needinfo

— Reply to this email directly, view it on GitHub https://github.com/microsoft/PowerToys/issues/28810#issuecomment-1737638901, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA7K2VAO765RB56I6I7LMHDX4RBQ7ANCNFSM6AAAAAA5JPYSKI . You are receiving this because you authored the thread.Message ID: @.***>

ssaari avatar Sep 27 '23 16:09 ssaari

This looks like a crash in PT Run and is unrelated to the update process.

PT Run failed to read the settings file of the shell plugin in local appdata folder. Maybe we need better error handling when reading the "wox" plugin settings files using the wox code.

https://github.com/microsoft/PowerToys/blob/main/src/modules/launcher/Wox.Infrastructure/Storage/JsonStorage`1.cs

htcfreek avatar Sep 27 '23 17:09 htcfreek

@ssaari To investigate this we need the complete stack trace. Please upload a bug report. /bugreport

htcfreek avatar Sep 27 '23 17:09 htcfreek

@ssaari To investigate this we need the complete stack trace. Please upload a bug report. /bugreport

Sory. I saw the log file to late.

htcfreek avatar Sep 27 '23 17:09 htcfreek

System.UnauthorizedAccessException: Access to the path 'C:\Users\ssaari\AppData\Local\Microsoft\PowerToys\PowerToys Run\Settings\Plugins\Microsoft.Plugin.Shell\ShellPluginSettings.json' is denied.
   Source: System.Private.CoreLib
   TargetAssembly: System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
   TargetModule: System.Private.CoreLib.dll
   TargetSite: Microsoft.Win32.SafeHandles.SafeFileHandle CreateFile(System.String, System.IO.FileMode, System.IO.FileAccess, System.IO.FileShare, System.IO.FileOptions)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
   at System.IO.File.OpenHandle(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
   at System.IO.File.WriteToFile(String path, FileMode mode, String contents, Encoding encoding)
   at System.IO.Abstractions.FileWrapper.WriteAllText(String path, String contents)
   at Wox.Infrastructure.Storage.JsonStorage`1.Save()
   at Microsoft.Plugin.Shell.Main.Save()
   at Microsoft.Plugin.Shell.Main.UpdateSettings(PowerLauncherPluginSettings settings)
   at Wox.Plugin.PluginPair.Update(PowerLauncherPluginSettings setting, IPublicAPI api)
   at PowerLauncher.SettingsReader.ReadSettings()
   at PowerLauncher.App.<>c__DisplayClass19_0.<OnStartup>b__0()
   at Wox.Infrastructure.Stopwatch.Normal(String message, Action action)
   at PowerLauncher.App.OnStartup(Object sender, StartupEventArgs e)
   at System.Windows.Application.<.ctor>b__1_0(Object unused)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

htcfreek avatar Sep 27 '23 17:09 htcfreek

@ssaari , Does this still happen after a computer restart, or was it just once after install? /needinfo

jaimecbernardo avatar Sep 27 '23 19:09 jaimecbernardo

Hello,

It only occurred during the initial software update sequence.

Regards,

Scott Saari @.*** 602-230-7824

On Wed, Sep 27, 2023 at 1:11 PM Jaime Bernardo @.***> wrote:

@ssaari https://github.com/ssaari , Does this still happen after a computer restart, or was it just once after install? /needinfo

— Reply to this email directly, view it on GitHub https://github.com/microsoft/PowerToys/issues/28810#issuecomment-1737938910, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA7K2VBV3JMKODXPIVHYKQTX4R24PANCNFSM6AAAAAA5JPYSKI . You are receiving this because you were mentioned.Message ID: @.***>

ssaari avatar Oct 02 '23 16:10 ssaari

It's possible we have a racing condition while updating the settings? Or it might have been really just have been that file handle was still being used from the process installation? Anyway, it seems like this should be investigated to check if we can do some better handling here. Thanks for opening the issue!

jaimecbernardo avatar Oct 03 '23 07:10 jaimecbernardo

Hi, just wanted to mention that I get the error with 0.76.1.0, too. Pops up when logging into Windows.

Details

Version: 0.76.1.0 OS Version: Microsoft Windows NT 10.0.19044.0 IntPtr Length: 8 x64: True Date: 11.12.2023 06:40:14 Exception: System.UnauthorizedAccessException: Access to the path 'C:\Users\ma099801\AppData\Local\Microsoft\PowerToys\PowerToys Run\Settings\Plugins\Microsoft.Plugin.Shell\ShellPluginSettings.json' is denied. at Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options) at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable1 unixCreateMode) at System.IO.File.OpenHandle(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize) at System.IO.File.WriteToFile(String path, FileMode mode, String contents, Encoding encoding) at System.IO.Abstractions.FileWrapper.WriteAllText(String path, String contents) at Wox.Infrastructure.Storage.JsonStorage1.Save() at Microsoft.Plugin.Shell.Main.Save() at Microsoft.Plugin.Shell.Main.UpdateSettings(PowerLauncherPluginSettings settings) at Wox.Plugin.PluginPair.Update(PowerLauncherPluginSettings setting, IPublicAPI api, Action refreshPluginsOverviewCallback) at PowerLauncher.SettingsReader.ReadSettings() at PowerLauncher.App.<>c__DisplayClass19_0.<OnStartup>b__0() at Wox.Infrastructure.Stopwatch.Normal(String message, Action action) at PowerLauncher.App.OnStartup(Object sender, StartupEventArgs e) at System.Windows.Application.<.ctor>b__1_0(Object unused) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

Thanks, Mathias

MathiasRotter avatar Dec 11 '23 05:12 MathiasRotter

@jaimecbernardo Is this the bug that should be linked for duplicates? There were a few duplicates reported recently and I don't mind linking them to this bug if this is the one that is tracking the status.

nagolucky18 avatar Jan 16 '24 06:01 nagolucky18

I asume we can do this one if you find other bugs with the same error:

System.UnauthorizedAccessException: Access to the path 'C:\Users\ssaari\AppData\Local\Microsoft\PowerToys\PowerToys Run\Settings\Plugins\Microsoft.Plugin.Shell\ShellPluginSettings.json' is denied.

Thank you ;)

jaimecbernardo avatar Jan 16 '24 21:01 jaimecbernardo

This has been worked on during the 0.79.0 release cycle. Please update to the latest: https://github.com/microsoft/PowerToys/releases

jaimecbernardo avatar Mar 07 '24 14:03 jaimecbernardo