rust-lang / rust-lang/rust

bootstrap.py needs a lockfile to prevent concurrent invocations

Open
#143,756 2 comments 0 reactions 1 assignee View on GitHub

@lolbinarycat is already working on this.

Since Jul 12, 2025.

C-bug T-bootstrap
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Summary

cargo uses lockfiles to protect the build directory, however these only protect against parallel invocations of cargo, and bootstrap does a bunch of other file manipulations that

Command used
./x tidy & ./x tidy
Expected behaviour

One invocation acquires the lockfile, while the other blocks and waits for the lockfile to be unlocked, resuming once the first one is complete.

This is a problem because or rust-analyzer config recommends going through ./x check, which may cause build cache corruption if the user runs an ./x.py command at the same time r-a decides to do a check.

Actual behaviour

Both instances of bootstrap try to operate on the same files at the same time, causing one of them to crash.

Bootstrap configuration (bootstrap.toml)
profile = "tools"  # Includes one of the default files in src/bootstrap/defaults
change-id = 138986

rust.debuginfo-level = 1
#rust.jemalloc = true
rust.download-rustc = false
rust.deny-warnings = false
build.docs-minification = false
#build.incremental = false
build.tidy-extra-checks = "auto:py"
Operating system

Arch Linux

HEAD

78a6e132984dba0303ebad7dcfd1305c93ad5835

Additional context
Build Log

extracting /home/binarycat/src/rs/rust/build/cache/2025-06-24/rustc-beta-x86_64-unknown-linux-gnu.tar.xz
extracting /home/binarycat/src/rs/rust/build/cache/2025-06-24/rust-std-beta-x86_64-unknown-linux-gnu.tar.xz
extracting /home/binarycat/src/rs/rust/build/cache/2025-06-24/cargo-beta-x86_64-unknown-linux-gnu.tar.xz
Traceback (most recent call last):
  File "/home/binarycat/src/rs/rust/x.py", line 53, in <module>
    bootstrap.main()
    ~~~~~~~~~~~~~~^^
  File "/home/binarycat/src/rs/rust/src/bootstrap/bootstrap.py", line 1372, in main
    bootstrap(args)
    ~~~~~~~~~^^^^^^
  File "/home/binarycat/src/rs/rust/src/bootstrap/bootstrap.py", line 1337, in bootstrap
    build.download_toolchain()
    ~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/binarycat/src/rs/rust/src/bootstrap/bootstrap.py", line 696, in download_toolchain
    shutil.rmtree(bootstrap_build_artifacts)
    ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/shutil.py", line 763, in rmtree
    _rmtree_safe_fd(stack, onexc)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/shutil.py", line 704, in _rmtree_safe_fd
    onexc(func, path, err)
    ~~~~~^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/shutil.py", line 658, in _rmtree_safe_fd
    os.rmdir(name, dir_fd=dirfd)
    ~~~~~~~~^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/home/binarycat/src/rs/rust/build/bootstrap/debug'

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.