Skip to content

rust-analyzer settings should unset LD_LIBRARY_PATH #139155

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
jyn514 opened this issue Mar 30, 2025 · 0 comments
Open

rust-analyzer settings should unset LD_LIBRARY_PATH #139155

jyn514 opened this issue Mar 30, 2025 · 0 comments
Labels
C-bug Category: This is a bug. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@jyn514
Copy link
Member

jyn514 commented Mar 30, 2025

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)

@jyn514 jyn514 added C-bug Category: This is a bug. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Mar 30, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

No branches or pull requests

2 participants