Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

`./x check` being killed (by rust-analyzer) may leave `.git/index.lock` file

Open Beginner friendly
#163,751 6 comments 1 reaction 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
85/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust
Domain
build-system

Research direction

The problematic code path is traced in the stacktrace: git subprocesses are spawned from src/bootstrap/src/build_helper/git.rs (run_git_diff_index, changes_since), called via check_path_modifications in src/bootstrap/src/core/config/config.rs and detect_llvm_freshness in src/bootstrap/src/core/build_steps/llvm.rs. Review these locations to add logic that cleans up .git/index.lock if the x.py process is killed while the git subprocess is running. Verify the fix by triggering a check kill during git execution and confirming no lock file remains.

Written by the indexing model from the issue text.

Description

C-bug needs-triage T-bootstrap T-rust-analyzer
Summary

The python x.py check runs git update-index --refresh -q (indirectly in detect_llvm_freshness), which crates .git/index.lock. Normally wen git finishes the index.lock will be deleted.

In rust-analyzer flycheck.rs, it seems that when the previous python x.py check is still running, if check is triggered again, then the previous x process will be killed. If it kills the x process when the git subprocess is running, git will be killed and it will left .git/index.lock file.

When there is a leftover .git/index.lock I cannot do things like commit or push, so I have to manually delete the index.lock.

(I am using Windows, so maybe git runs slower, then it's more likely to trigger than other machines.)

Command used

VSCode rust-analyzer runs python x.py check --json-output --build-dir build-rust-analyzer

Expected behaviour

Not leaving .git/index.lock

Actual behaviour

Leaves .git/index.lock when no git process is running

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

Operating system

Windows 11

HEAD

Closest official commit is 28b6e691688c15cef4c60d9044274e7b84397870

Additional context

In bootstrap, the detect_llvm_freshness indirectly calls git update-index --refresh -q. Stacktrace:

   7: build_helper::git::run_git_diff_index::<build_helper::git::changes_since::{closure#0}, core::result::Result<alloc::vec::Vec<std::path::PathBuf>, alloc::string::String>>
   8: build_helper::git::changes_since
   9: build_helper::git::check_path_modifications
  10: bootstrap::core::config::config::impl$0::check_path_modifications::closure$0
             at .\src\bootstrap\src\core\config\config.rs:1873
  11: std::collections::hash::map::impl$72::or_insert_with::closure$0<alloc::vec::Vec<ref$<str$>,alloc::alloc::Global>,enum2$<build_helper::git::PathFreshness>,alloc::alloc::Global,bootstrap::core::config::config::impl$0::check_path_modifications::closure_env$0>
             at /rustc/cbae9b4cae2b108f6a3d18cfe6075714bb739463/library\std\src\collections\hash\map.rs:2540
  12: std::collections::hash::map::Entry::or_try_insert_with<alloc::vec::Vec<ref$<str$>,alloc::alloc::Global>,enum2$<build_helper::git::PathFreshness>,alloc::alloc::Global,std::collections::hash::map::impl$72::or_insert_with::closure_env$0<alloc::vec::Vec<ref$<s
             at /rustc/cbae9b4cae2b108f6a3d18cfe6075714bb739463/library\std\src\collections\hash\map.rs:2575
  13: std::collections::hash::map::Entry::or_insert_with<alloc::vec::Vec<ref$<str$>,alloc::alloc::Global>,enum2$<build_helper::git::PathFreshness>,alloc::alloc::Global,bootstrap::core::config::config::impl$0::check_path_modifications::closure_env$0>
             at /rustc/cbae9b4cae2b108f6a3d18cfe6075714bb739463/library\std\src\collections\hash\map.rs:2540
  14: bootstrap::core::config::config::Config::check_path_modifications
             at .\src\bootstrap\src\core\config\config.rs:1872
  15: bootstrap::core::build_steps::llvm::detect_llvm_freshness
             at .\src\bootstrap\src\core\build_steps\llvm.rs:327
  16: bootstrap::core::config::config::Config::maybe_download_ci_llvm
             at .\src\bootstrap\src\core\download.rs:281
  17: bootstrap::core::build_steps::llvm::try_download_ci_llvm
             at .\src\bootstrap\src\core\build_steps\llvm.rs:281
  18: bootstrap::core::build_steps::llvm::impl$4::run
             at .\src\bootstrap\src\core\build_steps\llvm.rs:410
  19: bootstrap::core::builder::Builder::ensure<bootstrap::core::build_steps::llvm::LlvmFromCi>
             at .\src\bootstrap\src\core\builder\mod.rs:1643
  20: bootstrap::core::build_steps::llvm::prebuilt_llvm_output
             at .\src\bootstrap\src\core\build_steps\llvm.rs:175
  21: bootstrap::core::build_steps::llvm::get_llvm_build_status
             at .\src\bootstrap\src\core\build_steps\llvm.rs:195
  22: bootstrap::core::build_steps::dist::maybe_install_llvm_target
             at .\src\bootstrap\src\core\build_steps\dist.rs:2610
  23: bootstrap::core::build_steps::compile::impl$15::run
             at .\src\bootstrap\src\core\build_steps\compile.rs:1962
  24: bootstrap::core::builder::Builder::ensure<bootstrap::core::build_steps::compile::Sysroot>
             at .\src\bootstrap\src\core\builder\mod.rs:1643
  25: bootstrap::core::builder::Builder::sysroot
             at .\src\bootstrap\src\core\builder\mod.rs:1339
  26: bootstrap::core::builder::impl$12::run
             at .\src\bootstrap\src\core\builder\mod.rs:730

(line numbers may not match because bootstrap code was changed for debugging. The issue occurs in unchanged bootstrap.)

Build Log

<log>

Dominant language
Rust
Stars
119k
Forks
17.3k
Avg merge
2d 8h
Merged PRs (30d)
544

Getting set up

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.

More from rust-lang/rust

All issues in rust-lang/rust

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.