【发布时间】:2020-06-01 19:07:40
【问题描述】:
从 WSL 升级到 WSL2 之后
sudo apt-get update
不再有效。之后:
wsl --set-version Ubuntu-18.04 2
输出是:
> sudo apt-get update
Err:1 http://security.ubuntu.com/ubuntu bionic-security InRelease
Temporary failure resolving 'security.ubuntu.com'
Err:2 http://archive.ubuntu.com/ubuntu bionic InRelease
Temporary failure resolving 'archive.ubuntu.com'
Err:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
Temporary failure resolving 'archive.ubuntu.com'
Err:4 http://archive.ubuntu.com/ubuntu bionic-backports InRelease
Temporary failure resolving 'archive.ubuntu.com'
Reading package lists... Done
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic/InRelease Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-updates/InRelease Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-backports/InRelease Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/bionic-security/InRelease Temporary failure resolving 'security.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.
返回 WSL1 后,问题再次消失。在 Debian 上也是如此,在 CentOS 上也是如此。所以 WSL2 肯定有一个错误。
Windows10 build 版本为 19041,今天安装。
WSL2 有什么解决方法吗? 问候
【问题讨论】:
-
删除
/etc/resolv.conf文件。关闭 WSL2 虚拟机。重新启动 WSL。检查您是否可以 ping 远程 IP 和网站。否则检查任何网络防火墙。 -
thx,/etc/resolv.conf 是正确的文件,但如果它被删除,它会在下一次 wsl 启动时重新生成
标签: ubuntu debian windows-subsystem-for-linux apt wsl-2