bootstrap: Try to track down why initial_libdir sometimes fails by Zalathar · Pull Request #129775 · rust-lang/rust (original) (raw)

When I try to run x commands from the command-line, I occasionally see a mysterious failure that looks something like this:

thread 'main' panicked at src/lib.rs:341:14:
called `Result::unwrap()` on an `Err` value: StripPrefixError(())

It happens often enough to be annoying, but rarely enough that I can't reproduce it at will. The error message points to a particular unwrap call, but doesn't include enough context to determine why the failure occurs.

Re-running the command almost always works, so I suspect some kind of filesystem race condition (possibly involving VSCode invoking bootstrap at the same time), but there's not much I can do with the information I currently have.

So this PR includes some relevant information in the panic message when the failure occurs, in the hope that doing so will make the cause easier to track down when the failure occurs again.