Skip to content

Rustup doesn't handle HTTP 416 errors when downloading toolchains #2071

@pietroalbini

Description

@pietroalbini

Problem

While setting up a Crater agent the container running Crater was killed for reasons in the middle of a rustup download. After starting the container again rustup kept failing with this error message:

info: downloading component 'rust-std'
error: component download failed for rust-std-x86_64-unknown-linux-gnu
error: caused by: could not download file from 'https://static.rust-lang.org/dist/2019-09-26/rust-std-1.38.0-x86_64-unknown-linux-gnu.tar.xz' to '/workspace/rustup-home/downloads/51b334337804baeff7524e5496d396f254894d7529860d236975e9ed8fcca371.partial'
error: caused by: http request returned an unsuccessful status code: 416

Steps

Note that these steps didn't cause the original bug, but they reproduce the same symptoms.

  1. Remove all partial downloads:
rm -f ~/.rustup/downloads/*.partial
  1. Install a toolchain, but kill rustup in the middle of a download.
  2. Increase the size of the only .partial file to 1 GB, way above the total size of the file:
fallocate -l 1G ~/.rustup/downloads/*.partial
  1. Try to reinstall the same toolchain, it will fail with:
error: component download failed for rust-std-x86_64-unknown-linux-gnu
error: caused by: could not download file from 'https://static.rust-lang.org/dist/2019-01-01/rust-std-nightly-x86_64-unknown-linux-gnu.tar.xz' to '/home/pietro/.rustup/downloads/63e41b2768326b80fbf9bdef657bb3c717319538e75b52dce305bc4363dce1f6.partial'
error: caused by: http request returned an unsuccessful status code: 416

Possible Solution(s)

The HTTP 416 status code means the content-range requested to the server was not satisfiable, which in our case means a corrupted (or overly large like in my repro steps) partial file. Rustup could handle this better by ignoring the partial and starting to download from scratch when it receives a 416 status code.

Notes

Output of rustup --version:

rustup 1.20.2 (13979c968 2019-10-16)

Output of rustup show: not relevant

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions