Post

rust-analyzer: Manually Reloading Workspace

rust-analyzer: Manually Reloading Workspace

rust-analyzer wasn’t picking up my Cargo.toml changes. Had to reload manually.

The Problem

Modified Cargo.toml to add a new dependency. rust-analyzer didn’t notice. LSP features (autocomplete, goto definition) didn’t work for the new crate.

Why It Happens

rust-analyzer doesn’t actively watch for file changes (open issue).

It loads the workspace once at startup. After that, you’re on your own.

The Solution

In Emacs with LSP mode:

1
M-x lsp-rust-analyzer-reload-workspace

rust-analyzer re-reads Cargo.toml and rebuilds its index.

For Other Editors

VS Code:

  • Command palette → “rust-analyzer: Reload Workspace”

Vim/Neovim with coc-rust-analyzer:

1
:CocCommand rust-analyzer.reloadWorkspace

Generic LSP:

  • Restart the LSP server

When to Reload

Reload after:

  • Adding/removing dependencies in Cargo.toml
  • Changing features
  • Adding new workspace members
  • Modifying build.rs

Basically, any change that affects project structure.

Alternative

Just restart your editor. Slower, but guaranteed to work.

But for quick iterations, manual reload is faster.

This post is licensed under CC BY 4.0 by the author.