xChar
·3 months ago

yay安装失败的解决方案
由于众所周知的原因,国内网络无法正常安装yay,故写下此篇文章。
希望这篇文章为安装yay提供参考,避免踩坑。

常规安装方法#

git clone https://aur.archlinux.org/yay
cd yay
makepkg -si

通常情况执行完上面所示命令即可安装成功,但是经常会遇到网络错误的情况,主要原因有如下两点

go语言的软件安装源被屏蔽
github访问受限
所以解决思路要么采取魔法软件,或者采取我以下所说的方法。
解决方案#
go语言换源
本文采用Goproxy.cn源,官网有换源方法,这里也贴出来

换源

go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct

使更换的源生效

临时生效

export GO111MODULE=on
export GOPROXY=https://goproxy.cn

永久生效

echo "export GO111MODULE=on" >> ~/.profile
echo "export GOPROXY=https://goproxy.cn" >> ~/.profile
source ~/.profile

完成以上步骤以后,可以再次尝试

makepkg -si
若还存在网络问题可以继续往下看,修改hosts

修改hosts访问github
本文采用的gitee找到的github hosts
github hosts如下:

# GitHub Host Start
185.199.108.154              github.githubassets.com
140.82.112.22                central.github.com
185.199.108.133              desktop.githubusercontent.com
185.199.108.153              assets-cdn.github.com
185.199.108.133              camo.githubusercontent.com
185.199.108.133              github.map.fastly.net
199.232.69.194               github.global.ssl.fastly.net
140.82.114.3                 gist.github.com
185.199.108.153              github.io
140.82.113.3                 github.com
140.82.112.5                 api.github.com
185.199.108.133              raw.githubusercontent.com
185.199.108.133              user-images.githubusercontent.com
185.199.108.133              favicons.githubusercontent.com
185.199.108.133              avatars5.githubusercontent.com
185.199.108.133              avatars4.githubusercontent.com
185.199.108.133              avatars3.githubusercontent.com
185.199.108.133              avatars2.githubusercontent.com
185.199.108.133              avatars1.githubusercontent.com
185.199.108.133              avatars0.githubusercontent.com
185.199.108.133              avatars.githubusercontent.com
140.82.112.10                codeload.github.com
52.217.207.1                 github-cloud.s3.amazonaws.com
52.216.78.4                  github-com.s3.amazonaws.com
52.217.194.169               github-production-release-asset-2e65be.s3.amazonaws.com
52.216.131.131               github-production-user-asset-6210df.s3.amazonaws.com
52.216.28.204                github-production-repository-file-5c1aeb.s3.amazonaws.com
185.199.108.153              githubstatus.com
64.71.144.202                github.community
185.199.108.133              media.githubusercontent.com

Please Star : https://github.com/ineo6/hosts

Mirror Repo : https://gitee.com/ineo6/hosts

Update at: 2021-12-01 08:39:41

GitHub Host End

修改hosts

sudo vim /etc/hosts
将以上github host内容追加到/etc/hosts文件中
使更新的hosts立即生效

sudo systemctl restart nscd


作者:tickltock

出处:https://www.cnblogs.com/tickltock/p/16480395.html

版权:本作品采用「署名-非商业性使用-相同方式共享 4.0 国际」许可协议进行许可。

Loading comments...