You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Chocolatey升级任意软件包时卡顿故障排查求助

Chocolatey升级卡顿问题的排查与修复

问题概述

以管理员身份升级任意软件包时,Chocolatey卡在Performing other installation steps阶段,单CPU核心满载,但内存、磁盘无活动。终止进程后,Chocolatey标记软件包为已更新,但实际未完成升级。重装Chocolatey、系统还原均无效。

典型卡顿输出

You have Firefox v109.0.1 installed. Version 110.0 is available based on your source(s).
Progress: Downloading Firefox 110.0... 100%

Firefox v110.0 [Approved]
firefox package files upgrade completed. Performing other installation steps.

终止进程后提示

Exiting chocolatey abnormally. Please manually clean up anything that was not finished.

调试日志信息

启用调试模式后,Freenet升级的关键日志片段:

freenet v0.7.5.1496 [Approved]
freenet package files upgrade completed. Performing other installation steps.
Setting installer args for freenet
Setting package parameters for freenet
Contents of 'C:\ProgramData\chocolatey\lib\freenet\tools\chocolateyInstall.ps1':
$ErrorActionPreference = 'Stop';

$packageArgs = @{
  packageName    = 'freenet'
  fileType       = 'exe'
  url            = 'https://github.com/freenet/fred/releases/download/build01496/FreenetInstaller-1496.exe'
  silentArgs     = '/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-'
  validExitCodes = @(0)
  softwareName   = 'Freenet*'
  checksum       = 'd88d37d2e212bf87d9710bc10b1d07f508944e052e1825220ed50310d717261d'
  checksumType   = 'sha256'
  toolsDir       = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
}
Install-ChocolateyPackage @packageArgs

Calling built-in PowerShell host with ['[System.Threading.Thread]::CurrentThread.CurrentCulture = '';[System.Threading.Thread]::CurrentThread.CurrentUICulture = ''; & import-module -name 'C:\ProgramData\chocolatey\helpers\chocolateyInstaller.psm1'; & 'C:\ProgramData\chocolatey\helpers\chocolateyScriptRunner.ps1' -packageScript 'C:\ProgramData\chocolatey\lib\freenet\tools\chocolateyInstall.ps1' -installArguments '' -packageParameters '' -preRunHookScripts $null -postRunHookScripts $null']
Redirecting System.Management.Automation.resources, Version=3.0.0.0, Culture=ru-RU, PublicKeyToken=31bf3856ad364e35, requested by ''

排查与修复步骤

1. 解决PowerShell文化设置冲突

日志显示存在俄语文化(ru-RU)的资源重定向,可能导致PowerShell执行卡顿:

  • 打开管理员PowerShell,执行以下命令强制设置英文文化:
    [System.Threading.Thread]::CurrentThread.CurrentCulture = 'en-US'
    [System.Threading.Thread]::CurrentThread.CurrentUICulture = 'en-US'
    
  • 再运行Chocolatey升级命令,例如:choco upgrade firefox -y

2. 手动执行安装脚本定位问题

直接运行软件包的安装脚本,确认是脚本本身还是安装程序的问题:

  • 以Freenet为例,执行:
    & 'C:\ProgramData\chocolatey\lib\freenet\tools\chocolateyInstall.ps1'
    
  • 如果脚本卡顿,手动下载安装包并测试静默安装:
    FreenetInstaller-1496.exe /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-
    
    若手动安装也卡顿,说明是软件安装程序的静默模式问题,需更换包源或反馈给包维护者。

3. 排查Chocolatey钩子脚本

自定义钩子可能导致卡顿:

  • 暂时重命名C:\ProgramData\chocolatey\hooks目录,再尝试升级。

4. 验证PowerShell执行环境

  • 确保执行策略允许运行脚本:
    Set-ExecutionPolicy RemoteSigned -Scope LocalMachine
    
  • 重新导入Chocolatey模块并确认命令存在:
    Import-Module C:\ProgramData\chocolatey\helpers\chocolateyInstaller.psm1
    Get-Command Install-ChocolateyPackage
    

5. 检查进程资源死锁

卡顿期间,用Process Explorer查看choco.exe或powershell.exe的线程状态,确认是否有线程等待文件锁、注册表项等资源,针对性释放或修复。


内容的提问来源于stack exchange,提问作者Eugene Kuklin

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.01 01:35:17