-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add rust-analyzer.serverEnv to set the environment variables of the server #6099
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Browsing through the PR, just saw this comment: #5954 (comment) I guess I did it 😄 |
matklad
reviewed
Oct 6, 2020
Comment on lines
+479
to
+483
"rust-analyzer.serverEnv": { | ||
"type": "object", | ||
"default": null, | ||
"description": "Environment variables to set for the rust-analyzer executable in form of { \"key\": \"value\"}" | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's name this server.env
. I should have renamed serverPath
to server.path
long ago...
This would be great! I just ran into this problem (via #6007) this morning 😄 |
rib
added a commit
to rib/cargo
that referenced
this pull request
Nov 7, 2020
Some custom build scripts (especially for -sys packages) expect to query environment variables to locate build resources (such as pre-built binaries) but these cause lots of trouble when considering the numerous different ways in which cargo may be invoked. For example each editor that invokes cargo as part of providing development diagnostics needs to offer some way to configure environment variables or users need to find their own way of controlling the environment variables of these different tools which is burdensome and can lead to an inconsistent duplication of state across tools. This introduces support for reading an (optional) environment.json found at the root of the current workspace that may contain a map of environment variable key, value pairs. These variables will be exported to all build scripts run under the workspace. The removes any need to configure tools and editors independently. The configuration is separate from any Config.toml since it's likely that the state shouldn't be under version control in many situations (generally locating resources for the project within a specific user's development environment). Fixes: rust-lang/issues/4121 Fixes: rust-lang/rls/issues/915 Fixes: rust-lang/vscode-rust/issues/791 Fixes: rust-lang/rust-analyzer/pull/6099 Fixes: intellij-rust/intellij-rust/issues/1569
superseded by #7091 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR simply adds a
rust-analyzer.serverEnv
settings in the VSCode extension to set the environment variables used when launching the rust-analyzer server.I don't know if it is a common use case, but I have a build script that depends on an environment variable to locate a system dependency. If the environment variable changes, the build script is re-run (which takes some time). The environment variables changes frequently, as I jump from version to version. I was setting the environment variable in the terminal of VS Code, but it kept re-running the build script because rust-analyzer was overiding the build script hash value. A quick fix was to launch VS Code from a terminal with the environment variable set, but it seemed like a nice feature to add without much effort needed, so there it is.