rust-lang / rust-lang/rust-analyzer
rust-analyzer doesn’t enable/pass a feature with `cargo.features` to a build script
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
Converting to an issue since I see no way this would be intended behavior, and I haven't been able to solve it myself.
I have "rust-analyzer.cargo.features": ["scrap/linux-pkg-config"] in a .vscode/settings.json, but it seemingly doesn't want to work.
Build script fails on this function, with VCPKG_ROOT not found..., which is code it shouldn't be getting to given that using pkg-config is enabled and I'm not setting NO_PKG_CONFIG_* anywhere.
Manually running the command does work:
» cargo check --workspace --message-format=json-diagnostic-rendered-ansi --manifest-path /path/to/Cargo.toml --keep-going --all-targets --features scrap/linux-pkg-config
(whole load of diagnostics text)
Using some logging suggests that the feature isn't being enabled at all after a server restart:
Caused by:
process didn't exit successfully:...
--- stdout
Starting build script...
...
Checking config for linux-pkg-config feature: false
Checking NO_PKG_CONFIG variable value: Err(NotPresent)
Using homebrew
target_os: linux, target_arch: x86_64
Originally posted by @4JX in https://github.com/rust-lang/rust-analyzer/discussions/18416
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
Reproduce the issue with the .vscode/settings.json cargo.features setting and the supplied cargo check command, then compare the rust-analyzer build invocation with the manual command. Use the referenced libs/scrap/build.rs logging to verify whether the feature reaches the build script; done means rust-analyzer passes scrap/linux-pkg-config and the build script observes it as enabled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100