Skip to content
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

rust-analyzer doesn't read [env] values from .cargo/config.toml #13976

Closed
recatek opened this issue Jan 18, 2023 · 1 comment · Fixed by #16554
Closed

rust-analyzer doesn't read [env] values from .cargo/config.toml #13976

recatek opened this issue Jan 18, 2023 · 1 comment · Fixed by #16554
Assignees
Labels
A-cargo cargo related issues A-proc-macro proc macro C-enhancement Category: enhancement E-has-instructions Issue has some instructions and pointers to code to get started

Comments

@recatek
Copy link

recatek commented Jan 18, 2023

I'm using environment variables to configure proc macros that need to open and parse files for generation. When building in cargo, I can set these in the [env] block of .cargo/config.toml. However, rust-analyzer doesn't read these environment variables, forcing me to duplicate them as settings with rust-analyzer.server.extraEnv.

rust-analyzer version: rust-analyzer version: 0.3.1369-standalone
rustc version: rustc 1.66.0 (69f9c33d7 2022-12-12)

@jonas-schievink jonas-schievink added the A-proc-macro proc macro label Jan 18, 2023
@Veykril Veykril added A-cargo cargo related issues C-enhancement Category: enhancement labels Feb 9, 2023
@Veykril
Copy link
Member

Veykril commented Oct 16, 2023

Two things here, we should fetch the env section via cargo config get like we do here

cargo_config
.current_dir(cargo_toml.parent())
.args(["-Z", "unstable-options", "config", "get", "build.target"])
.env("RUSTC_BOOTSTRAP", "1");
and then pass these to where we start the proc-macro server. (We should also make sure that env! expansion checks these vars).

The other thing is that we should watch the .cargo/config.toml for changes and re-fetch the section(s) on change.

@Veykril Veykril added the E-has-instructions Issue has some instructions and pointers to code to get started label Oct 16, 2023
@Veykril Veykril self-assigned this Jan 31, 2024
@bors bors closed this as completed in a02a219 Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cargo cargo related issues A-proc-macro proc macro C-enhancement Category: enhancement E-has-instructions Issue has some instructions and pointers to code to get started
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants