Skip to content

rust-analyzer settings should unset LD_LIBRARY_PATH #139155

Open
@jyn514

Description

@jyn514

Summary

x check rebuilds rustc_llvm frequently because LD_LIBRARY_PATH is set by rustup when running rust-analyzer.

I noticed that x check was rebuilding rustc_llvm basically every time I modified a source file. I tracked this down to the following env variable change:

cargo::core::compiler::fingerprint:     dirty: EnvVarChanged { name: "REAL_LIBRARY_PATH", old_value: Some("/home/jyn/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib"), new_value: None }

The problem was that I had installed rust-analyzer from rustup, not as a standalone tool. As a result, rustup sets
LD_LIBRARY_PATH=$(rustc --print target-libdir) in the environment under the assumption that rust-analyzer needs it to link to rustc_private crates. This can in fact happen; see rust-lang/rustup#4245 (comment).

To avoid this, we should add rust-analyzer.cargo.extraEnv = { LD_LIBRARY_PATH = null } to the default settings. That unsets it only for commands spawned by rust-analyzer, while keeping direct invocations of x the same.

Command used

x check compiler

Bootstrap configuration (bootstrap.toml)

profile = "compiler"
change-id = 137170

[rust]
deny-warnings = false

Operating system

PopOS 22.04 (Ubuntu derivative)

HEAD

i'm currently on fedf107. i don't remember what commit i was on when i first saw this bug; i assume it is still present.

Additional context

; rustup which rust-analyzer
/home/jyn/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rust-analyzer
; rust-analyzer --version
rust-analyzer 1.87.0-nightly (43f0014 2025-03-25)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions