为什么在 Windows 10 上安装 Chocolatey 期间 7-Zip 失败?

Why is 7-Zip failing during this Chocolatey installation on Windows 10?

我正在尝试安装 Chocolatey

https://chocolatey.org/install

并使用命令:

@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"

显示错误:

Unable to unzip package using 7zip. Perhaps try setting $env:chocolateyUseWindowsCompression = 'true' and call install
again. Error: 7-Zip encountered a fatal error while extracting the files
At line:221 char:9
+     2 { throw "$errorMessage 7-Zip encountered a fatal error while ex ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (Unable to unzip...cting the files:String) [], RuntimeException
    + FullyQualifiedErrorId : Unable to unzip package using 7zip. Perhaps try setting $env:chocolateyUseWindowsCompres
   sion = 'true' and call install again. Error: 7-Zip encountered a fatal error while extracting the files

我安装了 7zip。

几个月后,我 运行 从具有 管理权限 的 cmd 命令中执行相同的命令,并且成功了。重点是 运行

cmd.exe As an Administrator.

当我尝试在多个服务器上安装 chocolatey 时遇到了同样的错误,最终在 chocolatey 服务器上被阻止,这是一个 chocolatey 功能。

https://chocolatey.org/docs/community-packages-disclaimer#rate-limiting

因此下载的文件为空,无法解压。一小时后解除封锁。解除速率限制后,错误消失,直到您再次触发它。

速率限制也适用于其他包。当下载 chocolatey 本身以外的包时达到限制,您将收到错误代码 429。

https://chocolatey.org/docs/troubleshooting#im-getting-a-429-too-many-requests-issue-when-attempting-to-use-the-community-package-repository

我遇到了同样的问题

运行 window cmd 作为管理员可能是某些人的解决方案,但就我而言,我不得不更新我的 window 系统环境变量, 我只是将其添加到现有价值中 路径: $env:chocolateyUseWindowsCompression = 'true' 一切正常。

第一个答案:运行 window cmd 作为管理员可能是某些人的解决方案,但在我的情况下,我不得不更新我的 window 系统环境变量,我只是将其添加到路径上的现有值:$env:chocolateyUseWindowsCompression = 'true' 一切正常。

可能无法立即工作,您仍然收到 "Unable to unzip package using 7zip." 错误。

重启机器后重试。在我的例子中,命令在重新启动后有效。

谢谢 卡拉姆