Skip to content

allow using null to unset an environment variable #19629

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jyn514
Copy link
Member

@jyn514 jyn514 commented Apr 19, 2025

this makes three changes:

  • all callsites of toolchain::command are changed to use command(path, extra_env), instead of manually adding the env after the fact.
  • all map<str, str> are changed to map<str, option<str>>.
  • command checks for None and calls env_remove if so.

this caught several places where environment variables weren't being propagated:

  • when running rustc --print=target-libdir
  • when running cargo rustc -- --print=target-spec-json
  • when running the custom DiscoverLinkedProjects config. I think this is for use with non-cargo build systems, so I didn't change it.

i verified locally that this actually works.

fixes #19626

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 19, 2025
@jyn514
Copy link
Member Author

jyn514 commented Apr 19, 2025

cc @davidbarsky for the DiscoverCommand changes; should cargo.extraEnv or check.extraEnv apply there? right now they don’t.

this makes three changes:
- all callsites of `toolchain::command` are changed to use
  `command(path, extra_env)`, instead of manually adding the env after
  the fact.
- all `map<str, str>` are changed to `map<str, option<str>>`.
- `command` checks for None and calls `env_remove` if so.

this caught several places where environment variables weren't being
propagated:
- when running `rustc --print=target-libdir`
- when running `cargo rustc -- --print=target-spec-json`
- when running the custom DiscoverLinkedProjects config. I *think* this
  is for use with non-cargo build systems, so I didn't change it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

setting rust-analyzer.cargo.extraEnv.key = null has no effect
2 participants