WSL配置源
前言
WSL安装g++显示找不到包,于是定位到源的问题,看了很多大多是 /etc/apt/sources.list 文件下更新成国内源,然后执行sudo apt-get update sudo apt-get upgrade,前者是更新软件列表,后者是软件升级,结果update就报错:
Ign:1 http://mirrors.aliyun.com/ubuntu jammy InRelease
Ign:2 http://mirrors.aliyun.com/ubuntu jammy-security InRelease
Ign:3 http://mirrors.aliyun.com/ubuntu jammy-updates InRelease
Ign:4 http://mirrors.aliyun.com/ubuntu jammy-backports InRelease
Ign:5 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy InRelease
Ign:6 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-updates InRelease
Ign:7 http://mirrors.163.com/ubuntu jammy InRelease
Ign:8 http://mirrors.163.com/ubuntu jammy-security InRelease
Ign:9 http://mirrors.163.com/ubuntu jammy-updates InRelease
Ign:10 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-backports InRelease
Ign:11 http://mirrors.163.com/ubuntu jammy-backports InRelease
Ign:12 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-security InRelease
Ign:1 http://mirrors.aliyun.com/ubuntu jammy InRelease
Ign:5 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy InRelease
Ign:7 http://mirrors.163.com/ubuntu jammy InRelease
Ign:8 http://mirrors.163.com/ubuntu jammy-security InRelease
Ign:2 http://mirrors.aliyun.com/ubuntu jammy-security InRelease
Ign:3 http://mirrors.aliyun.com/ubuntu jammy-updates InRelease
Ign:6 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-updates InRelease
Ign:10 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-backports InRelease
Ign:9 http://mirrors.163.com/ubuntu jammy-updates InRelease
Ign:11 http://mirrors.163.com/ubuntu jammy-backports InRelease
Ign:4 http://mirrors.aliyun.com/ubuntu jammy-backports InRelease
Ign:12 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-security InRelease
Ign:5 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy InRelease
Ign:6 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-updates InRelease
Ign:7 http://mirrors.163.com/ubuntu jammy InRelease
Ign:1 http://mirrors.aliyun.com/ubuntu jammy InRelease
Ign:10 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-backports InRelease
Ign:12 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-security InRelease
Ign:8 http://mirrors.163.com/ubuntu jammy-security InRelease
Ign:9 http://mirrors.163.com/ubuntu jammy-updates InRelease
Ign:2 http://mirrors.aliyun.com/ubuntu jammy-security InRelease
Ign:3 http://mirrors.aliyun.com/ubuntu jammy-updates InRelease
Ign:11 http://mirrors.163.com/ubuntu jammy-backports InRelease
Ign:4 http://mirrors.aliyun.com/ubuntu jammy-backports InRelease
Err:1 http://mirrors.aliyun.com/ubuntu jammy InRelease
Temporary failure resolving 'mirrors.aliyun.com'
Err:5 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy InRelease
Temporary failure resolving 'mirrors.tuna.tsinghua.edu.cn'
Err:2 http://mirrors.aliyun.com/ubuntu jammy-security InRelease
Temporary failure resolving 'mirrors.aliyun.com'
Err:7 http://mirrors.163.com/ubuntu jammy InRelease
Temporary failure resolving 'mirrors.163.com'
Err:6 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-updates InRelease
Temporary failure resolving 'mirrors.tuna.tsinghua.edu.cn'
Err:3 http://mirrors.aliyun.com/ubuntu jammy-updates InRelease
Temporary failure resolving 'mirrors.aliyun.com'
Err:4 http://mirrors.aliyun.com/ubuntu jammy-backports InRelease
Temporary failure resolving 'mirrors.aliyun.com'
Err:10 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-backports InRelease
Temporary failure resolving 'mirrors.tuna.tsinghua.edu.cn'
Err:12 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-security InRelease
Temporary failure resolving 'mirrors.tuna.tsinghua.edu.cn'
Err:8 http://mirrors.163.com/ubuntu jammy-security InRelease
Temporary failure resolving 'mirrors.163.com'
Err:9 http://mirrors.163.com/ubuntu jammy-updates InRelease
Temporary failure resolving 'mirrors.163.com'
Err:11 http://mirrors.163.com/ubuntu jammy-backports InRelease
Temporary failure resolving 'mirrors.163.com'
Reading package lists... Done
W: Failed to fetch http://mirrors.aliyun.com/ubuntu/dists/jammy/InRelease Temporary failure resolving 'mirrors.aliyun.com'
W: Failed to fetch http://mirrors.aliyun.com/ubuntu/dists/jammy-security/InRelease Temporary failure resolving 'mirrors.aliyun.com'
W: Failed to fetch http://mirrors.aliyun.com/ubuntu/dists/jammy-updates/InRelease Temporary failure resolving 'mirrors.aliyun.com'
W: Failed to fetch http://mirrors.aliyun.com/ubuntu/dists/jammy-backports/InRelease Temporary failure resolving 'mirrors.aliyun.com'
W: Failed to fetch https://mirrors.tuna.tsinghua.edu.cn/ubuntu/dists/jammy/InRelease Temporary failure resolving 'mirrors.tuna.tsinghua.edu.cn'
W: Failed to fetch https://mirrors.tuna.tsinghua.edu.cn/ubuntu/dists/jammy-updates/InRelease Temporary failure resolving 'mirrors.tuna.tsinghua.edu.cn'
W: Failed to fetch https://mirrors.tuna.tsinghua.edu.cn/ubuntu/dists/jammy-backports/InRelease Temporary failure resolving 'mirrors.tuna.tsinghua.edu.cn'
W: Failed to fetch https://mirrors.tuna.tsinghua.edu.cn/ubuntu/dists/jammy-security/InRelease Temporary failure resolving 'mirrors.tuna.tsinghua.edu.cn'
W: Failed to fetch http://mirrors.163.com/ubuntu/dists/jammy/InRelease Temporary failure resolving 'mirrors.163.com'
W: Failed to fetch http://mirrors.163.com/ubuntu/dists/jammy-security/InRelease Temporary failure resolving 'mirrors.163.com'
W: Failed to fetch http://mirrors.163.com/ubuntu/dists/jammy-updates/InRelease Temporary failure resolving 'mirrors.163.com'
W: Failed to fetch http://mirrors.163.com/ubuntu/dists/jammy-backports/InRelease Temporary failure resolving 'mirrors.163.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.
(注:源更新注意系统版本,不同版本有不同代号:
Ubuntu 22.04:jammy
Ubuntu 20.04:focal
Ubuntu 18.04:bionic
Ubuntu 16.04:xenia)
按照网上帖子在/etc/resolv.conf中添加nameserver 8.8.8.8或者nameserver 114.114.114.114
,执行update,报错仍如上,发现这个文件是系统每次启动时自动生成,修改没用;然后在/etc/wsl.conf中添加:
[network]
generateResolvConf = false
重启后重新在/etc/resolv.conf中添加nameserver 8.8.8.8或者nameserver 114.114.114.114
,成功。
遇见:E: Unable to locate package gcc,如果源配置没问题的话,就重新执行:sudo apt-get install gcc。