Skip to content

ruff has some cache bug that causes crashes #12158

@hauntsaninja

Description

@hauntsaninja

Here's a directory structure that repros:

λ tree                        
.
└── dir
    ├── prefix
    │   ├── abc
    │   │   └── __init__.py
    │   └── pyproject.toml
    ├── prefixabc
    │   └── pyproject.toml
    └── pyproject.toml

5 directories, 4 files

Contents don't matter.

If you run ruff twice, you'll crash with:

warning: Different package root in cache: expected '/Users/shantanu/tmp/ruffcrash/dir/prefixabc', got '/Users/shantanu/tmp/ruffcrash/dir/prefix/abc'
error: Panicked while linting dir/prefixabc/pyproject.toml: This indicates a bug in Ruff. If you could open an issue at:

    https://github.com/astral-sh/ruff/issues/new?title=%5BLinter%20panic%5D

...with the relevant file contents, the `pyproject.toml` settings, and the following stack trace, we'd be very appreciative!

panicked at crates/ruff/src/diagnostics.rs:195:18:
wrong package cache for file
Backtrace:    0: std::backtrace::Backtrace::force_capture
   1: std::backtrace::Backtrace::force_capture
   2: <ruff::panic::PanicError as core::fmt::Display>::fmt
   3: std::panicking::rust_panic_with_hook
   4: <std::panicking::begin_panic_handler::StaticStrPayload as core::panic::PanicPayload>::take_box
   5: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
   6: _rust_begin_unwind
   7: core::panicking::panic_fmt
   8: <core::panic::panic_info::PanicInfo as core::fmt::Display>::fmt
   9: core::option::expect_failed
  10: <ruff::diagnostics::FixMap as core::ops::arith::AddAssign>::add_assign
  11: <ruff::panic::PanicError as core::fmt::Display>::fmt
  12: ruff::check
  13: <ruff::version::VersionInfo as core::fmt::Display>::fmt
  14: <ruff::args::LogLevelArgs as clap_builder::derive::Args>::augment_args
  15: <ruff::panic::PanicError as core::fmt::Display>::fmt
  16: <ruff::args::LogLevelArgs as clap_builder::derive::Args>::augment_args
  17: <ruff::panic::PanicError as core::fmt::Display>::fmt
  18: ruff::check
  19: rayon_core::registry::WorkerThread::wait_until_cold
  20: rayon_core::registry::ThreadBuilder::run
  21: <rayon_core::unwind::AbortIfPanic as core::ops::drop::Drop>::drop
  22: <rayon_core::registry::WorkerThread as core::convert::From<rayon_core::registry::ThreadBuilder>>::from
  23: std::sys::pal::unix::thread::Thread::new
  24: __pthread_start

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggreat writeupA wonderful example of a quality contribution

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions