Ubuntu 18.04 sudo apt-get updateコマンド が Failed to fetchエラーになった時の解決法


目的

  • コマンドsudo apt-get updateを実行した際にFailed to fetchエラーが出たときの解決法を知る。

実行環境

  • OS
    Ubuntu18.04(WSL)

エラー内容

shun@DESKTOP-AO64T0U:~$ sudo apt-get update
Get:1 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Hit:2 http://archive.ubuntu.com/ubuntu bionic InRelease
Get:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
Get:4 http://archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]
Get:5 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages [523 kB]
Get:6 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [746 kB]
Get:7 http://security.ubuntu.com/ubuntu bionic-security/main Translation-en [175 kB]
Get:8 http://security.ubuntu.com/ubuntu bionic-security/restricted amd64 Packages [8192 B]
Get:9 http://security.ubuntu.com/ubuntu bionic-security/restricted Translation-en [3180 B]
Get:10 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 Packages [608 kB]
Get:11 http://archive.ubuntu.com/ubuntu bionic-updates/main Translation-en [268 kB]
Ign:12 http://security.ubuntu.com/ubuntu bionic-security/universe Translation-en
Get:13 http://security.ubuntu.com/ubuntu bionic-security/multiverse amd64 Packages [4904 B]
Get:14 http://security.ubuntu.com/ubuntu bionic-security/multiverse Translation-en [2396 B]
Get:12 http://security.ubuntu.com/ubuntu bionic-security/universe Translation-en [203 kB]
Err:12 http://security.ubuntu.com/ubuntu bionic-security/universe Translation-en
File has unexpected size (202408 != 202600). Mirror sync in progress? [IP: 91.189.88.173 80]
Hashes of expected file:
- Filesize:202600 [weak]
- SHA256:d5644557978bdf7fdd90693bebb82c40ab026134bce6a0878f892fe222d37f75
- SHA1:c40f41430f0e0571a11f5a1f2308a0ee0c339899 [weak]
- MD5Sum:8c8b9c42ecf2348f66b13f1608f38234 [weak]
Release file created at: Tue, 01 Oct 2019 13:01:35 +0000
Get:15 http://archive.ubuntu.com/ubuntu bionic-updates/restricted amd64 Packages [15.1 kB] 
Get:16 http://archive.ubuntu.com/ubuntu bionic-updates/restricted Translation-en [4844 B]
Get:17 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages [1007 kB]
Get:18 http://archive.ubuntu.com/ubuntu bionic-updates/universe Translation-en [309 kB]
Get:19 http://archive.ubuntu.com/ubuntu bionic-updates/multiverse amd64 Packages [7556 B]
Get:20 http://archive.ubuntu.com/ubuntu bionic-updates/multiverse Translation-en [3868 B]
Get:21 http://archive.ubuntu.com/ubuntu bionic-backports/universe amd64 Packages [4020 B]
Fetched 3942 kB in 43s (92.2 kB/s)
Reading package lists... Done
E: Failed to fetch http://security.ubuntu.com/ubuntu/dists/bionic-security/universe/i18n/Translation-en.xz  File has unexpected size (202408 != 202600). Mirror sync in progress? [IP: 91.189.88.173 80]
Hashes of expected file:
- Filesize:202600 [weak]
- SHA256:d5644557978bdf7fdd90693bebb82c40ab026134bce6a0878f892fe222d37f75
- SHA1:c40f41430f0e0571a11f5a1f2308a0ee0c339899 [weak]
- MD5Sum:8c8b9c42ecf2348f66b13f1608f38234 [weak]
Release file created at: Tue, 01 Oct 2019 13:01:35 +0000
E: Some index files failed to download. They have been ignored, or old ones used instead.

解決法

  • 先人の知恵によりコマンドsudo apt-get updateを実行した際のパッケージリストが悪さをしていることが分かった。
  • パッケージリストを先に削除してあげることで正常にコマンドsudo apt-get updateが実行できた。
  1. 下記コマンドを実行してパッケージリストを削除する。
  $ sudo rm -rf /var/lib/apt/lists/*
  1. 今一度、コマンドsudo apt-get updateを実行する。
  $ sudo apt-get update
  1. 下記の様に出力されればコマンドsudo apt-get updateが正常に実行できている。
  shun@DESKTOP-AO64T0U:~$ sudo apt-get update
  Get:1 http://archive.ubuntu.com/ubuntu bionic InRelease [242 kB]
  Get:2 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
  Get:3 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages [523 kB]
  Get:4 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
  Get:5 http://security.ubuntu.com/ubuntu bionic-security/main Translation-en [175 kB]
  Get:6 http://security.ubuntu.com/ubuntu bionic-security/restricted amd64 Packages [8192 B] 
  Get:7 http://archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]
  Get:8 http://security.ubuntu.com/ubuntu bionic-security/restricted Translation-en [3180 B]
  Get:9 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 Packages [608 kB]
  Get:10 http://archive.ubuntu.com/ubuntu bionic/main amd64 Packages [1019 kB]
  Get:11 http://security.ubuntu.com/ubuntu bionic-security/universe Translation-en [203 kB]
  Get:12 http://security.ubuntu.com/ubuntu bionic-security/multiverse amd64 Packages [4904 B]
  Get:13 http://security.ubuntu.com/ubuntu bionic-security/multiverse Translation-en [2396 B]
  Get:14 http://archive.ubuntu.com/ubuntu bionic/main Translation-en [516 kB]
  Get:15 http://archive.ubuntu.com/ubuntu bionic/restricted amd64 Packages [9184 B]
  Get:16 http://archive.ubuntu.com/ubuntu bionic/restricted Translation-en [3584 B]
  Get:17 http://archive.ubuntu.com/ubuntu bionic/universe amd64 Packages [8570 kB]
  Get:18 http://archive.ubuntu.com/ubuntu bionic/universe Translation-en [4941 kB]
  Get:19 http://archive.ubuntu.com/ubuntu bionic/multiverse amd64 Packages [151 kB]
  Get:20 http://archive.ubuntu.com/ubuntu bionic/multiverse Translation-en [108 kB]
  Get:21 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [746 kB]
  Get:22 http://archive.ubuntu.com/ubuntu bionic-updates/main Translation-en [268 kB]
  Get:23 http://archive.ubuntu.com/ubuntu bionic-updates/restricted amd64 Packages [15.1 kB]
  Get:24 http://archive.ubuntu.com/ubuntu bionic-updates/restricted Translation-en [4844 B]
  Get:25 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages [1006 kB]
  Get:26 http://archive.ubuntu.com/ubuntu bionic-updates/universe Translation-en [309 kB]
  Get:27 http://archive.ubuntu.com/ubuntu bionic-updates/multiverse amd64 Packages [7552 B]
  Get:28 http://archive.ubuntu.com/ubuntu bionic-updates/multiverse Translation-en [3868 B]
  Get:29 http://archive.ubuntu.com/ubuntu bionic-backports/main amd64 Packages [2512 B]
  Get:30 http://archive.ubuntu.com/ubuntu bionic-backports/main Translation-en [1644 B]
  Get:31 http://archive.ubuntu.com/ubuntu bionic-backports/universe amd64 Packages [4020 B]
  Get:32 http://archive.ubuntu.com/ubuntu bionic-backports/universe Translation-en [1856 B]
  Fetched 19.7 MB in 2min 5s (158 kB/s)
  Reading package lists... Done