Does rust-analyzer need more crates than building?

I always run rust-analyzer in a bwrap sandbox with network disabled; when I add crates I manually run cargo fetch outside the sandbox, and it had been working great. Recently I found calling tracing::info! triggers errors from rust-analyzer, saying "unresolved macro line" --- I guess it may be complaining about std::line!. I tried running rust-analyzer outside my sandbox once, and it appears to have downloaded something I'm not sure, and then those errors are gone, even with sandbox on again. The projects builds, so I must have all dependencies, so are there extra crates I need to fetch for rust-analyzer?

EDIT I looked for mtime=today in my ~/.cargo, seems these crates were added today:

  • compiler_builtins-0.1.123
  • proc-macro2-1.0.89
  • syn-2.0.85
  • rand_xorshift-0.3.0
  • cc-1.0.99
  • pin-project-lite-0.2.15

Is compiler_builtins than one? This does not appear in tracing's dependency tree, however.

Likely it's fetching dependencies (which are used for tests).

std itself has some dependencies that need to be fetched so RA can analyze them. You could fetch them using this command:

cd $(rustc --print sysroot)/lib/rustlib/src/rust/library && __CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS=nightly cargo metadata

(the channel override is necessary because the std Cargo.toml uses nightly features.)

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.