Skip to content

Commit

Permalink
fix: std Cargo.lock moved to library dir
Browse files Browse the repository at this point in the history
#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
```
  • Loading branch information
weihanglo committed Aug 8, 2024
1 parent f50c592 commit 50237f4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/cargo/core/compiler/standard_lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -192,7 +192,8 @@ fn detect_sysroot_src_path(target_data: &RustcTargetData<'_>) -> CargoResult<Pat
.join("lib")
.join("rustlib")
.join("src")
.join("rust");
.join("rust")
.join("library");
let lock = src_path.join("Cargo.lock");
if !lock.exists() {
let msg = format!(
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/standard_lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ fn setup() -> 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"]);
Expand Down

0 comments on commit 50237f4

Please sign in to comment.