rust-lang / rust-lang/rustup

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

Open
#2,942 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Rust
Stars
7k
Forks
1.1k
Avg merge
22h 40m
Merged PRs (30d)
46

Description

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)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the manifest setup from the issue, then inspect src/toolchain.rs at get_component_suggestion and the related logic in src/dist/manifest.rs, especially the handling of empty bins. Done means component operations no longer panic when pkg.rust has no url or xz_url, while the listed sub-components remain available.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.