rust-lang / rust-lang/rust-analyzer

/cargo/cfgs map instead of sequence

Open
#19,658 3 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-config C-bug
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

Had a weird bug where RA wouldn't analyze my workspace due to some deserialization issue with /cargo/cfgs

rust-analyzer WARN GlobalState::handle_event{event=Event::Lsp}: Failed to deserialize config field at /cargo/cfgs: Error( invalid type: map, expected a sequence , line: 0, column: 0)

Failed to deserialize config field at /cargo/cfgs: Error( invalid type: map, expected a sequence

Took me a while to figure out how to fix it, but I was able to find a solution. Posting it here in case anyone else hits the same issue.

TLDR: somehow if this "cfgs" thing is unset, it passes a map {} instead of an array [ ]
To fix it, you just need to find the default here:

https://rust-analyzer.github.io/book/configuration.html#cargo.cfgs

and set those in the VS Code Settings UI:
Image

Setting these here, reminded VS Code to pass an array of cfgs instead of a map, and RA accepted the config object

(probably json configuration works too, but I never know which json it uses)


rust-analyzer version: (eg. output of "rust-analyzer: Show RA Version" command, accessible in VSCode via Ctrl/⌘+Shift+P)

rustc version: rustc 1.88.0-nightly (b8c54d635 2025-04-20)

editor or extension: VS Code - server version 0.4.2432

relevant settings: n/a

Contributor guide

Open the contributing guide

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.

Research direction

Start by reproducing the /cargo/cfgs deserialization warning in VS Code with the setting unset, then trace the configuration handling that reports the error. Check the configuration documentation entry for cargo.cfgs and determine whether the unset value should be accepted or documented differently; done means the reported scenario has a confirmed resolution and regression coverage if applicable.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, vscode
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.