WSL2のUbuntu18.04LTSでapt updateエラー
Windows Insider Program のスローリングでもWSL2が使えるようになりましたが、セットアップするとはまったので記録しておきます。
原因
時刻のずれによりapt update
が正しく動作しない。
対応
WSL2でも使える sudo date -s [時刻]
で時刻を設定後、apt update
する。
内容
apt-updateで下記エラー
noguchi@DESKTOP-H406S9B:~$ sudo apt-get update [sudo] password for noguchi: Hit:1 http://archive.ubuntu.com/ubuntu bionic InRelease Get:2 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB] Get:3 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB] Get:4 http://archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB] Reading package lists... Done E: Release file for http://archive.ubuntu.com/ubuntu/dists/bionic-updates/InRelease is not valid yet (invalid for another 15h 41min 37s). Updates for this repository will not be applied. E: Release file for http://security.ubuntu.com/ubuntu/dists/bionic-security/InRelease is not valid yet (invalid for another 12h 16min 17s). Updates for this repository will not be applied. E: Release file for http://archive.ubuntu.com/ubuntu/dists/bionic-backports/InRelease is not valid yet (invalid for another 12h 18min 13s). Updates for this repository will not be applied. noguchi@DESKTOP-H406S9B:~$
参考URLの情報より、時刻のずれが原因と判明。
WSL2の場合、systemd関係のコマンドやtimedatectlコマンドも怒られるので下記コマンドで時刻設定後正しくupdateできた。
noguchi@DESKTOP-H406S9B:~$ date Wed Dec 11 07:03:21 JST 2019 noguchi@DESKTOP-H406S9B:~$ sudo date -s "2019/12/11 23:19:30" Wed Dec 11 23:19:30 JST 2019 noguchi@DESKTOP-H406S9B:~$ sudo apt-get update Hit:1 http://archive.ubuntu.com/ubuntu bionic InRelease Get:3 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB] Get:2 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB] Get:5 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages [593 kB] Get:4 http://archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB] Get:6 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [816 kB] Get:7 http://security.ubuntu.com/ubuntu bionic-security/main Translation-en [194 kB] Get:8 http://security.ubuntu.com/ubuntu bionic-security/restricted amd64 Packages [15.1 kB] Get:9 http://security.ubuntu.com/ubuntu bionic-security/restricted Translation-en [4684 B] Get:10 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 Packages [626 kB] Get:11 http://archive.ubuntu.com/ubuntu bionic-updates/main Translation-en [288 kB] Get:12 http://archive.ubuntu.com/ubuntu bionic-updates/restricted amd64 Packages [24.1 kB] Get:13 http://archive.ubuntu.com/ubuntu bionic-updates/restricted Translation-en [6620 B] Get:14 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages [1033 kB] Get:15 http://security.ubuntu.com/ubuntu bionic-security/universe Translation-en [209 kB] Get:16 http://security.ubuntu.com/ubuntu bionic-security/multiverse amd64 Packages [6120 B] Get:17 http://security.ubuntu.com/ubuntu bionic-security/multiverse Translation-en [2600 B] Get:18 http://archive.ubuntu.com/ubuntu bionic-updates/universe Translation-en [319 kB] Get:19 http://archive.ubuntu.com/ubuntu bionic-updates/multiverse amd64 Packages [9284 B] Get:20 http://archive.ubuntu.com/ubuntu bionic-updates/multiverse Translation-en [4508 B] Get:21 http://archive.ubuntu.com/ubuntu bionic-backports/main amd64 Packages [2512 B] Get:22 http://archive.ubuntu.com/ubuntu bionic-backports/main Translation-en [1644 B] Get:23 http://archive.ubuntu.com/ubuntu bionic-backports/universe amd64 Packages [4028 B] Get:24 http://archive.ubuntu.com/ubuntu bionic-backports/universe Translation-en [1856 B] Fetched 4414 kB in 5s (856 kB/s) Reading package lists... Done noguchi@DESKTOP-H406S9B:~$