We have a
.env file with variables that are needed by the project to compile. The build task is setup using just. Just automatically applies
.env file in the project root, so the compilation works as intended. But the rust-analyzer obviously does not see these environment variables and shows compilation errors in various parts of the project.
I know that I can add these variables in the workspace's
settings.json file using
rust-analyzer.cargo.extraEnv, but that would be a duplication of data and also I do not want to commit these variables into version control but
setting.json is there.
What I'm thinking of is wrapping the rust language server executable in some script that will apply
.env and then run the language server. But I have no idea how to approach this. But maybe there are other possibilities.