Skip to content

Panic: no value set for FileSourceRootQuery #11357

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Tracked by #11387 ...
agrover opened this issue Jan 27, 2022 · 9 comments · Fixed by #12002
Closed
Tracked by #11387 ...

Panic: no value set for FileSourceRootQuery #11357

agrover opened this issue Jan 27, 2022 · 9 comments · Fixed by #12002
Labels
Broken Window Bugs / technical debt to be addressed immediately C-bug Category: bug I-panic S-actionable Someone could pick this issue up and work on it right now

Comments

@agrover
Copy link

agrover commented Jan 27, 2022

Happens every time I git checkout a significantly older version of my Rust project that I'm using rust-analyzer on. Using rust-analyzer via emacs and lsp.

See salsa-rs/salsa#254 : "This is a rust-analyzer bug". "Sounds like you made an input query and then tried to use it like an on-demand one. Input queries have to have a value in them before you can read one."

thread 'main' panicked at 'no value set for FileSourceRootQuery(FileId(6447))', /home/agrover/.cargo/registry/src/github.com.-1ecc6299db9ec823/salsa-0.17.0-pre.2/src/input.rs:106:32
stack backtrace:
   0: rust_begin_unwind
             at /rustc/db9d1b20bba1968c1ec1fc49616d4742c1725b4b/library/std/src/panicking.rs:498:5
   1: core::panicking::panic_fmt
             at /rustc/db9d1b20bba1968c1ec1fc49616d4742c1725b4b/library/core/src/panicking.rs:107:14
   2: <salsa::input::InputStorage<Q> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch::{{closure}}
   3: <salsa::input::InputStorage<Q> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
   4: <DB as base_db::SourceDatabaseExt>::file_source_root::__shim
   5: <core::iter::adapters::copied::Copied<I> as core::iter::traits::iterator::Iterator>::fold
   6: <base_db::SourceRootCratesQuery as salsa::plumbing::QueryFunction>::execute
   7: salsa::runtime::Runtime::execute_query_implementation
   8: salsa::derived::slot::Slot<Q,MP>::read_upgrade
   9: salsa::derived::slot::Slot<Q,MP>::read
  10: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  11: <DB as base_db::SourceDatabaseExt>::source_root_crates::__shim
  12: <base_db::FileLoaderDelegate<&T> as base_db::FileLoader>::relevant_crates
  13: <ide_db::RootDatabase as base_db::FileLoader>::relevant_crates
  14: rust_analyzer::global_state::GlobalState::process_changes
  15: rust_analyzer::reload::<impl rust_analyzer::global_state::GlobalState>::switch_workspaces
  16: rust_analyzer::main_loop::<impl rust_analyzer::global_state::GlobalState>::handle_event
  17: rust_analyzer::main_loop::<impl rust_analyzer::global_state::GlobalState>::run
  18: rust_analyzer::main_loop::main_loop
  19: rust_analyzer::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "SendError(..)"', /home/agrover/.cargo/registry/src/github.com.-1ecc6299db9ec823/lsp-server-0.5.2/src/stdio.rs:29:37
stack backtrace:
   0: rust_begin_unwind
             at /rustc/db9d1b20bba1968c1ec1fc49616d4742c1725b4b/library/std/src/panicking.rs:498:5
   1: core::panicking::panic_fmt
             at /rustc/db9d1b20bba1968c1ec1fc49616d4742c1725b4b/library/core/src/panicking.rs:107:14
   2: core::result::unwrap_failed
             at /rustc/db9d1b20bba1968c1ec1fc49616d4742c1725b4b/library/core/src/result.rs:1613:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Process rust-analyzer stderr finished

rust-analyzer version: (eg. output of "Rust Analyzer: Show RA Version" command)
rust-analyzer 8b779e8 2022-01-21 dev

rustc version: (eg. output of rustc -V)
rustc 1.58.1 (db9d1b20b 2022-01-20)

@Veykril Veykril added Broken Window Bugs / technical debt to be addressed immediately C-bug Category: bug labels Jan 28, 2022
@Veykril
Copy link
Member

Veykril commented Jan 28, 2022

Needs a reproduction to be actionable

@Veykril Veykril added the S-unactionable Issue requires feedback, design decisions or is blocked on other work label Jan 28, 2022
@agrover
Copy link
Author

agrover commented Jan 28, 2022

@Veykril 100% reproducible for me. In what format do you need reproduction?

@Veykril
Copy link
Member

Veykril commented Jan 28, 2022

A repro for which this is reproducible, just git checkout isn't enough as this has yet to happen for me in any repo.

@lnicola lnicola mentioned this issue Jan 31, 2022
15 tasks
@agrover
Copy link
Author

agrover commented Feb 21, 2022

  1. checkout rust-analyzer repo master branch
  2. open crates/cfg/src/lib.rs or another file that existed at the start of 2021, in Emacs.
  3. rust-analyzer should do a bunch of stuff
  4. in a terminal run git checkout 2021-01-04
  5. Should see above stack trace in rust-analyzer::stderr and should get the prompt: Server rust-analyzer:<num> exited with status exit(check corresponding stderr buffer for details). Do you want to restart it? (y or n)

for reference my Emacs init.el is here.

@Veykril
Copy link
Member

Veykril commented Feb 22, 2022

So the problem here seems to be https://github.com./rust-analyzer/rust-analyzer/blob/2e124d15fb72482257c8ef10369df77ee24d6a85/crates/rust-analyzer/src/global_state.rs#L193
where we use a query before potentially setting up the source root for the file, which is required in the query.

I expected calling a query at that part would be fishy when I implemented that...

@Veykril Veykril added S-actionable Someone could pick this issue up and work on it right now S-unactionable Issue requires feedback, design decisions or is blocked on other work and removed S-unactionable Issue requires feedback, design decisions or is blocked on other work labels Feb 22, 2022
@lnicola lnicola removed the S-unactionable Issue requires feedback, design decisions or is blocked on other work label Feb 23, 2022
@bors bors closed this as completed in 20e6065 Apr 15, 2022
@zanieb
Copy link

zanieb commented Apr 22, 2024

👋 Hi! I'm encountering this issue again in VSCode e.g.

thread 'LspServer' panicked at /Users/runner/work/rust-analyzer/rust-analyzer/crates/salsa/src/input.rs:91:32:
no value set for FileSourceRootQuery(FileId(8982))
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: <salsa::input::InputStorage<Q> as salsa::plumbing::QueryStorageOps<Q>>::fetch
   3: <DB as base_db::SourceDatabaseExt>::file_source_root
   4: base_db::change::FileChange::apply
   5: hir_expand::change::ChangeWithProcMacros::apply
   6: ide_db::apply_change::<impl ide_db::RootDatabase>::apply_change
   7: rust_analyzer::global_state::GlobalState::process_changes
   8: rust_analyzer::main_loop::<impl rust_analyzer::global_state::GlobalState>::handle_event
   9: rust_analyzer::main_loop::<impl rust_analyzer::global_state::GlobalState>::run
  10: rust_analyzer::main_loop::main_loop
  11: rust_analyzer::run_server
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread '<unnamed>' panicked at /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lsp-server-0.7.6/src/stdio.rs:28:37:
receiver was dropped, failed to send a message: "SendError(..)"
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::result::unwrap_failed
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread 'main' panicked at /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/jod-thread-0.1.2/src/lib.rs:33:22:
called `Result::unwrap()` on an `Err` value: Any { .. }
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::result::unwrap_failed
   3: jod_thread::JoinHandle<T>::join
   4: stdx::thread::JoinHandle<T>::join
   5: rust_analyzer::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Error - 12:24:43 PM] Client Rust Analyzer Language Server: connection to server is erroring. Shutting down server.

Is there anything that could have caused this to regress again? Let me know if you think a new issue is warranted — I can try to get a reproduction but for now this is occurring while working in astral-sh/uv. It happens a couple times a day. As described here and in the related issues, this usually occurs when switching branches.

@Veykril Veykril reopened this Apr 23, 2024
@Veykril
Copy link
Member

Veykril commented Apr 23, 2024

It was never fully fixed I think, the root cause is still somewhat unknown.

@Veykril
Copy link
Member

Veykril commented Apr 28, 2024

#17145 should hopefully fix this for good

@Veykril Veykril closed this as completed Apr 28, 2024
@zanieb
Copy link

zanieb commented Apr 28, 2024

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Broken Window Bugs / technical debt to be addressed immediately C-bug Category: bug I-panic S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants