RA doesn't properly resolve _relative_ env vars from .cargo/config.toml
#18143
Labels
C-bug
Category: bug
.cargo/config.toml
#18143
rust-analyzer version:
rust-analyzer version: 0.3.2112-standalone (94b526fc8 2024-09-15) [/Users/greg/.vscode/extensions/rust-lang.rust-analyzer-0.3.2112-darwin-arm64/server/rust-analyzer]
rustc version:
rustc 1.81.0 (eeb90cda1 2024-09-04)
editor or extension: vscode
v0.3.2112
relevant settings:
Any
.cargo/config.toml
setting a relative env var. For example:rust-analyzer/.cargo/config.toml
Lines 12 to 13 in 990c48c
repository link (if public, optional):
code snippet to reproduce:
The
[env]
table in.cargo/config.toml
allows for values to specified as relative paths, in which case they should be resolved to absolute paths that are relative to the.cargo
dir. See https://doc.rust-lang.org/cargo/reference/config.html#env. An example is:Rust-Analyzer does not convert this to a proper absolute path.
The relevant code is here:
rust-analyzer/crates/project-model/src/env.rs
Lines 72 to 113 in 990c48c
We an see that RA runs a command like:
cargo -Zunstable-options config get env
, which will output something like the following, assuming the example toml snippet above:We can see that RA strips the
.value
suffixrust-analyzer/crates/project-model/src/env.rs
Line 106 in 990c48c
and ignores the
.relative
field.A Fix
One way to fix this would be to compute the absolute path by joining the relative path with the config file's path.
The text was updated successfully, but these errors were encountered: