现象
执行下面的命令安装vcredist140
# 安装Chocolatey
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
Start-Sleep -s 30
choco
# 安装vcredist140
choco install --accept-license -y vcredist140
报错信息如下:
PS C:\Windows\system32> choco install --accept-license -y vcredist140 -s 'https://community.chocolatey.org/api/v2/'
Chocolatey v2.2.2
Installing the following packages:
vcredist140
By installing, you accept licenses for the packages.
Failed to fetch results from V2 feed at 'http://community.chocolatey.org/api/v2/FindPackagesById?id='chocolatey-core.extension'&$skiptoken='1712192601110','1.0.1','chocolatey-core.extension'' with following message : An error occurred while sending the request.
Failed to fetch results from V2 feed at 'http://community.chocolatey.org/api/v2/FindPackagesById?id='kb3033929'&$skiptoken='1712096301283','1.0.0','kb3033929'' with following message : An error occurred while sending the request.
Failed to fetch results from V2 feed at 'http://community.chocolatey.org/api/v2/FindPackagesById?id='kb2919355'&$skiptoken='1712245703703','1.0.20160719','kb2919355'' with following message : An error occurred while sending the request.
Failed to fetch results from V2 feed at 'http://community.chocolatey.org/api/v2/FindPackagesById?id='kb2999226'&$skiptoken='1711612100460','1.0.20161030','kb2999226'' with following message : An error occurred while sending the request.
Unable to resolve dependency 'chocolatey-core.extension'. Source(s) used: 'https://community.chocolatey.org/api/v2/'.
解决方法
尝试过choco install --accept-license --force chocolatey-core.extension
安装缺失依赖包仍然不成功
只好添加--ignore-dependencies
或者-i
参数绕过chocolatey-core.extension
依赖
命令如下:
# 可以通过-s 参数指定源
choco install --accept-license -y vcredist140 --ignore-dependencies -s 'https://chocolatey.org/api/v2/'
其他方法,缺啥装啥
可以通过报错信息给的缺失依赖依次手动安装
例如:
# 安装vcredist140,只需要chocolatey-core.extension可以将后面的包去掉
choco install --accept-license -y --pre kb2919442 KB2919355 chocolatey-compatibility.extension chocolatey-core.extension chocolatey-windowsupdate.extension kb3035131 kb3033929 kb2999226 vcredist140
# 安装 7z
choco install --accept-license -y --pre 7zip.install 7zip
# 安装 openjdk17
choco install --accept-license -y --pre temurin17 openjdk17
# 安装 python3.12.3
choco install --accept-license -y --pre vcredist2015 python312
choco install --accept-license -y python3 --version 3.12.3
# 安装 git
choco install --accept-license -y --pre git.install git
关于choco的升级命令
choco upgrade chocolatey
参考
Can’t update pkg due to chocolatey-core.extension version mismatch