rust-lang / rust-lang/rust-analyzer
`UNRESOLVED_ENV_VAR` reported when add external rust file with `include!`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
The code is at repo for reproduce, you can build it with
BINDING_PATH=../../build/bindings.rs cargo build --manifest-path ./proj/Cargo.toml
However when editing in VSCode, rust-analyzer report UNRESOLVED_ENV_VAR on the include! macro:
I think I already set necessary variables in the settings.json
{
"rust-analyzer.cargo.extraEnv": {
"BINDING_PATH": "${workspaceFolder}/build/bindings.rs"
},
"rust-analyzer.check.extraEnv": {
"BINDING_PATH": "${workspaceFolder}/build/bindings.rs"
},
"rust-analyzer.restartServerOnConfigChange": true,
}
How can I eliminate this error and enable IntelliSense for the bindings crate?
rust-analyzer version: rust-analyzer version: 0.3.2029-standalone
rustc version: rustc 1.79.0 (129f3b996 2024-06-10)
editor or extension: VSCode
relevant settings: null
repository link (if public, optional): repo for reproduce
code snippet to reproduce:
You can find the code at the repository above
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 with the linked fre3dm4n/rust-analyzer-issue repository and reproduce the report using the documented BINDING_PATH and cargo build command. Then trace how rust-analyzer handles include! environment variables and the cargo.extraEnv/check.extraEnv settings; done means the false UNRESOLVED_ENV_VAR diagnostic is eliminated and IntelliSense works for the bindings crate.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100