Skip to content

uninstall coreutils will Failed to update PowerShell profiles in pwsh.exe loss #73

@a-rookie-of-C-language

Description

@a-rookie-of-C-language

因为卸载时会调用CurUninstallStepChanged最终会执行到pwsh.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -File ...\pwsh-install.ps1 -Action Uninstall,它默认我本机上有pwsh.exe,但是遗憾的是我本机并没有于是报错Failed to update PowerShell profiles
所以这个问题的关键是:
安装阶段有 DetectPowerShell,会判断有没有可用 PowerShell;但卸载阶段没有重新检测,直接尝试清理 PowerShell profile。于是没有 pwsh.exe 的机器上就会报错。

但是我看到在 #40 这个pr中已经修复了这个问题,但是我任然在本机出现了这种状况,似乎是这个pr修改的内容没有出现在最新的winget包中,但是我依旧发现了一些问题, #40 是一个很窄的修复,它没有避免这几种情况:

  • 卸载阶段仍然无条件调用InstallPowerShellProfiles(PWSH_SCOPE_NONE);
  • 卸载阶段没有重新 DetectPowerShell
  • 如果找到了某个 pwsh.exe,但脚本返回非 0,仍然会RaiseException('Failed to update PowerShell profiles...')然后整个卸载中断。
  • PowerShell profile 清理本质上只是“附带清理”,不应该阻止卸载主程序、移除 PATH、删除安装目录。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions