rustup icon indicating copy to clipboard operation
rustup copied to clipboard

Panic when no URLs are listed for `pkg.rust` in manifest

Open jonhoo opened this issue 2 years ago • 0 comments

Problem

I'm doing some work with slightly-modified manifests, and have run into a panic in Rustup that I wasn't expecting. It turns out that if you remove both url and xz_url from [pkg.rust.target.x86_64-unknown-linux-gnu] (or whatever your target may be), then any component-adding function (e.g., rustup component add rust-src) crashes here: https://github.com/rust-lang/rustup/blob/ce5817a94ac372804babe32626ba7fd2d5e1b6ac/src/toolchain.rs#L682

This is particularly odd since rustup never actually tries to download the rust binary artifacts, it just uses that pkg to figure out which components exist.

Steps

  1. Set up a mirror for https://static.rust-lang.org/dist/.
  2. Make the mirror modify channel-rust-stable.toml so that pkg.rust.target.* has no url or xz_url field.
  3. Make the mirror generate updated .sha256 and .asc files (with its own keypair).
  4. Invoke rustup component add rust-src with RUSTUP_DIST_SERVER and RUSTUP_PGP_KEY set for the mirror.

Possible Solution(s)

The absence of the (unused) binary artifacts for pkg.rust should not be used to indicate whether or not the various sub-components are available.

Notes

It's not entirely clear why this panic is triggered, since the components are all still there, but it seems something somewhere is ignoring components for packages that have no binary artifacts. I suspect it's related to https://github.com/rust-lang/rustup/blob/ce5817a94ac372804babe32626ba7fd2d5e1b6ac/src/dist/manifest.rs#L454-L456

but can't figure out where bins being empty is actually relevant. I'm guessing it's somehow https://github.com/rust-lang/rustup/blob/ce5817a94ac372804babe32626ba7fd2d5e1b6ac/src/dist/manifest.rs#L489-L491>

but can't tie it back to the code in get_component_suggestion.

Rustup version

rustup 1.24.3 (ce5817a94 2021-05-31)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.58.1 (db9d1b20b 2022-01-20)`

Installed toolchains

Default host: x86_64-unknown-linux-gnu
rustup home:  /home/jongje/.rustup

installed toolchains
--------------------

stable-x86_64-unknown-linux-gnu (default)
beta-x86_64-unknown-linux-gnu
nightly-x86_64-unknown-linux-gnu

active toolchain
----------------

stable-x86_64-unknown-linux-gnu (default)
rustc 1.58.1 (db9d1b20b 2022-01-20)

jonhoo avatar Feb 03 '22 23:02 jonhoo