Open Bpazy opened 2 years ago
Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')
但是脚本内的下载相关的地址为 github.com
和 raw.githubusercontent.com
,所以你还需要设置代理。我注意到网上很多博客,提到开启 Shadowsocks 的系统代理就可以正常安装了,但是实测仍不行,域名解析、内容下载仍会失败。
在查看源码后发现,安装脚本内访问网址和下载都是使用了 New-Object System.Net.WebClient
,所以这几种代理方式是肯定不生效的,就不要浪费时间了:
New-Object System.Net.WebClient
。New-Object System.Net.WebClient
。那么应该怎么做呢?其实官方文档里有提到:Using Scoop behind a proxy server 在运行安装脚本前,先用下面的脚本,给 WebClient 设置全局的、默认的代理:
# If you want to use a proxy that isn't already configured in Internet Options
[net.webrequest]::defaultwebproxy = new-object net.webproxy "http://proxy.example.org:8080"
# If you want to use the Windows credentials of the logged-in user to authenticate with your proxy
[net.webrequest]::defaultwebproxy.credentials = [net.credentialcache]::defaultcredentials
# If you want to use other credentials (replace 'username' and 'password')
[net.webrequest]::defaultwebproxy.credentials = new-object net.networkcredential 'username', 'password'
最后吐槽自己一句,因为对 powershell, scoop, C# 都不熟悉,我是直接 fork 了 scoop 仓库,然后去源码里修改下载的地址,然后设置的代理,太傻了。
可能是存在什么 BUG,导致自定义 Bucket 的名称中带有 Main 时,会被误认为时主仓库,从而所有软件都会从此处安装。
开挖