From 50237f40493afd48cf4d25f5e29dbe07f4e203c8 Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Thu, 8 Aug 2024 00:28:55 -0400 Subject: [PATCH] fix: std Cargo.lock moved to `library` dir rust-lang/cargo#14358 didn't check the correct Cargo.lock existence Perhaps it was there so the test passed, but after a new nightly is out it is gone. ``` Blocking waiting for file lock on package cache error: "/home/user/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/Cargo.lock" does not exist, unable to build with the standard library, try: rustup component add rust-src --toolchain nightly-aarch64-apple-darwin note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ``` --- src/cargo/core/compiler/standard_lib.rs | 5 +++-- tests/testsuite/standard_lib.rs | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cargo/core/compiler/standard_lib.rs b/src/cargo/core/compiler/standard_lib.rs index 92b3474d3f0..a3b2ff8acd1 100644 --- a/src/cargo/core/compiler/standard_lib.rs +++ b/src/cargo/core/compiler/standard_lib.rs @@ -73,7 +73,7 @@ pub fn resolve_std<'gctx>( } let src_path = detect_sysroot_src_path(target_data)?; - let std_ws_manifest_path = src_path.join("library").join("Cargo.toml"); + let std_ws_manifest_path = src_path.join("Cargo.toml"); let gctx = ws.gctx(); // TODO: Consider doing something to enforce --locked? Or to prevent the // lock file from being written, such as setting ephemeral. @@ -192,7 +192,8 @@ fn detect_sysroot_src_path(target_data: &RustcTargetData<'_>) -> CargoResult Setup { fn enable_build_std(e: &mut Execs, setup: &Setup) { // First up, force Cargo to use our "mock sysroot" which mimics what // libstd looks like upstream. - let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/testsuite/mock-std"); + let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/testsuite/mock-std/library"); e.env("__CARGO_TESTS_ONLY_SRC_ROOT", &root); e.masquerade_as_nightly_cargo(&["build-std"]);