rust-lang / rust-lang/rust-analyzer
/cargo/cfgs map instead of sequence
Nobody has claimed this yet.
- 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:
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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