[Bug]: Upgrade with WinGet exit code: -1978335145
Component
Agent
Description
When upgrading the agent from a previous version, 0.11.0 i think, to 0.12.0 it worked fine, when trying to upgrade to 0.12.1 it returns an error code. Powershell is running as administrator.
PS C:\Users\Sn00zE> & iwr -useb https://get.beszel.dev/upgrade -OutFile "$env:TEMP\upgrade-agent.ps1"; & Powershell -ExecutionPolicy Bypass -File "$env:TEMP\upgrade-agent.ps1"
Beszel Agent Upgrade Script
===========================
Retrieving current service configuration...
Current service configuration retrieved successfully.
Current agent path: C:\Users\Sn00zE\AppData\Local\Microsoft\WinGet\Links\beszel-agent.exe
Upgrading beszel-agent...
Using WinGet for upgrade...
Upgrading beszel-agent with WinGet...
WinGet exit code: -1978335145
New agent path: C:\Users\Sn00zE\AppData\Local\Microsoft\WinGet\Links\beszel-agent.exe
Agent path has not changed. Service update not needed.
Upgrade completed successfully!
Running it manually
PS C:\Users\Sn00zE> winget upgrade --exact --id henrygd.beszel-agent --accept-source-agreements --accept-package-agreements
Found beszel-agent [henrygd.beszel-agent] Version 0.12.0
This application is licensed to you by its owner.
Microsoft is not responsible for, nor does it grant any licenses to, third-party packages.
Successfully verified installer hash
Extracting archive...
Successfully extracted archive
Starting package uninstall...
An unexpected error occurred while executing the command:
remove: Access is denied.: "C:\Users\Sn00zE\AppData\Local\Microsoft\WinGet\Packages\henrygd.beszel-agent_Microsoft.Winget.Source_8wekyb3d8bbwe\beszel-agent.exe"
Uninstall failed with exit code: 0x8a150003 : Executing command failed
Expected Behavior
Winget upgrade should succeed. Add a line to the powershell upgrade script to output the current installed version and the version its upgrading to, if the information is available. beszel-agent.exe has no Product Version or File Version information.
Steps to Reproduce
Not sure how to reproduce, probably needs the previous version again to test. Used the uninstall method for winget from the documentation:
nssm stop beszel-agent
nssm remove beszel-agent confirm
winget uninstall henrygd.beszel-agent
Reinstalled the agent using the system install command from the Dashboard.
After reinstall and running the upgrade command, agent is already updated.
PS C:\Users\Sn00zE> & iwr -useb https://get.beszel.dev/upgrade -OutFile "$env:TEMP\upgrade-agent.ps1"; & Powershell -ExecutionPolicy Bypass -File "$env:TEMP\upgrade-agent.ps1"
Beszel Agent Upgrade Script
===========================
Retrieving current service configuration...
Current service configuration retrieved successfully.
Current agent path: C:\Users\Sn00zE\AppData\Local\Microsoft\WinGet\Links\beszel-agent.exe
Upgrading beszel-agent...
Using WinGet for upgrade...
Upgrading beszel-agent with WinGet...
Package is already up to date.
New agent path: C:\Users\Sn00zE\AppData\Local\Microsoft\WinGet\Links\beszel-agent.exe
Agent path has not changed. Service update not needed.
Upgrade completed successfully!
Category
Other
Affected Metrics
Other
OS / Architecture
Windows 11 24H2 (Build 26100.4770)
Beszel version
0.11.1
Installation method
Binary
Configuration
& iwr -useb https://get.beszel.dev/upgrade -OutFile "$env:TEMP\upgrade-agent.ps1"; & Powershell -ExecutionPolicy Bypass -File "$env:TEMP\upgrade-agent.ps1"
Hub Logs
Agent Logs
I also experienced the remove: Access is denied. error when trying to upgrade from 0.11.0 to 0.12.0 (0.12.1 isn't in winget yet. The PR is still being processed).
It turned out that even after running nssm stop beszel-agent the agent process was still running which blocked the binary from being removed. After killing the process manually in the task manager the upgrade worked fine.
I updated the script yesterday, let me know if you have better luck with it. If nssm stop continues to be an issue then we'll try killing the process manually in the script.
https://beszel.dev/guide/upgrade-winget
Ran the script
PS C:\Users\Sn00zE> & iwr -useb https://get.beszel.dev/upgrade -OutFile "$env:TEMP\upgrade-agent.ps1"; & Powershell -ExecutionPolicy Bypass -File "$env:TEMP\upgrade-agent.ps1"
Beszel Agent Upgrade Script
===========================
Retrieving current service configuration...
Current service configuration retrieved successfully.
Current agent path: C:\Users\Sn00zE\AppData\Local\Microsoft\WinGet\Links\beszel-agent.exe
Stopping beszel-agent service...
beszel-agent: STOP: The operation completed successfully.
Upgrading beszel-agent...
Using WinGet for upgrade...
Upgrading beszel-agent with WinGet...
New agent path: C:\Users\Sn00zE\AppData\Local\Microsoft\WinGet\Links\beszel-agent.exe
Agent path has not changed. Restarting service...
Starting beszel-agent service...
beszel-agent: START: The operation completed successfully.
Success! The beszel-agent service is running properly.
Upgrade completed successfully!
checked the agent version
PS C:\Users\Sn00zE> winget list henrygd.beszel-agent
Name Id Version Source
-------------------------------------------------
beszel-agent henrygd.beszel-agent 0.12.1 winget