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 fails with "error: config value env is not set" #17739

Closed
shanebishop opened this issue Jul 29, 2024 · 15 comments · Fixed by #17744
Closed

rust-analyzer fails with "error: config value env is not set" #17739

shanebishop opened this issue Jul 29, 2024 · 15 comments · Fixed by #17744
Labels
C-bug Category: bug

Comments

@shanebishop
Copy link

shanebishop commented Jul 29, 2024

rust-analyzer version: 0.3.2053-standalone

rustc version: rustc 1.79.0 (129f3b996 2024-06-10)

editor or extension: VSCode

relevant settings: RUSTC_WRAPPER="$HOME/.cargo/bin/sccache"

repository link (if public, optional):

code snippet to reproduce: N/A

environment: WSL 2, Ubuntu 22.04 x86_64

Error

When I open my workspace in VSCode, rust-analyzer doesn't show any red underlines for syntactically incorrect code. When I look at the output of rust-analyzer in the OUTPUT tab, I see this:

2024-07-29T18:56:36.485666Z ERROR Failed to discover cargo config env: cd "/home/shane/src/redacted" && RUSTC_BOOTSTRAP="1" RUSTUP_TOOLCHAIN="/home/shane/.rustup/toolchains/stable-x86_64-unknown-linux-gnu" "/home/shane/.cargo/bin/cargo" "-Z" "unstable-options" "config" "get" "env" failed, exit status: 101
stderr:
error: config value env is not set

Stack backtrace:
0: anyhow::error::::msg
1: project_model::utf8_stdout
2: project_model::env::cargo_config_env
3: project_model::workspace::ProjectWorkspace::load
4: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
5: <alloc::vec::Vec as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
6: core::ops::function::FnOnce::call_once{{vtable.shim}}
7: std::sys_common::backtrace::__rust_begin_short_backtrace
8: core::ops::function::FnOnce::call_once{{vtable.shim}}
9: std::sys::pal::unix::thread::Thread::new::thread_start
10: <unknown>
11: <unknown>

In case it is relevant, here is the Cargo.toml in the root of my workspace:

[workspace]
resolver = "2"
members = [ "hydra", "li_engine", "lich"]
exclude = [ "c_library_bindings" ]

[profile.release]
opt-level = "z"
strip = true
lto = true
#codegen-units = 1
@shanebishop shanebishop added the C-bug Category: bug label Jul 29, 2024
@SebastianTianying
Copy link

I am having the same error. seems like an issue with the latest update. Installing previous versions in VSCode fixed it for me.

@effervescentia
Copy link

I can confirm I have the same issue with VSCode despite everything working a few months ago with the same setup
I've actually tried multiple different IDEs (Nova, Zed) and found they also fail to highlight errors in code
I'm using cargo / rust v1.72.1

@Systemcluster
Copy link

As a workaround you can simply add an empty env section to your .cargo/config.toml:

[env]

@martin-fs
Copy link

I tried the [env] workaround and it didn't seem to fix things for me: the "config value env is not set" errors went away, but I couldn't navigate my source, even after restarting the server and VSCode a couple of times. I switched to a version from a month ago and things started working again immediately. 🤷

@alibektas
Copy link
Member

I tried the [env] workaround and it didn't seem to fix things for me: the "config value env is not set" errors went away, but I couldn't navigate my source, even after restarting the server and VSCode a couple of times. I switched to a version from a month ago and things started working again immediately. 🤷

Would you mind sharing some details ? rustc version rust-analyzer version etc. I am trying to come up with a test case but couldn't make that happen :)

@alibektas alibektas self-assigned this Jul 29, 2024
@alibektas
Copy link
Member

I am working on this until someone who knows what they are doing takes over 😃

@martin-fs
Copy link

@alibektas I did some poking around and it seems that the last working version for me is v0.3.2037 (e9afba5 2024-07-14). 0.3.2045 has the same problem, so it may not be related to this issue, which I think is a regression with the latest version 0.3.2053?

My project is on an older version of rustc, so I ran into #17662 , and I added the "rust-analyzer.server.extraEnv": { "RUSTUP_TOOLCHAIN": "stable" } workaround suggested there, then ran into this issue after running rustup toolchain install stable-aarch64-apple-darwin and upgrading to rustc 1.80.0.

I'm not sure what other details are relevant, if I should start bisecting, etc.

@alibektas
Copy link
Member

This is more than enough. Thanks!

@alibektas
Copy link
Member

I can also confirm that the problem is elsewhere. I can reproduce the error but everything works just fine. Without a repro it is hard for me track it down. Sorry!

@alibektas alibektas removed their assignment Jul 30, 2024
@Veykril
Copy link
Member

Veykril commented Jul 30, 2024

Note this error is harmless. The only reason this happens now is that we log the failure case unconditionally which we shouldn't do. Likely suffices to turn the tracing span from error to debug

@ievr
Copy link

ievr commented Jul 30, 2024

Having same issue on Win10 VSCode as well.
(Thank you for the bug report as it saved me a lot of time.)

@sirasistant
Copy link

sirasistant commented Jul 30, 2024

This repository is also affected by this issue. I cannot navigate the source (and I also get the error log about the [env], altough it appears to be harmless) on the last release (or prerelease) channel version, but I can in v0.3.2037

@alibektas
Copy link
Member

alibektas commented Jul 30, 2024

This issue will be closed but for those of you who can't use some of the rust-analyzer features. This issue is not related to that. I will be looking into what the actual cause for that is . I will be posting a reference to the issue once I figured out the main cause. 👋

@teknalb
Copy link

teknalb commented Jul 30, 2024

This repo have same issue with rust-analyzer, and other cyclic deps errors.

@Veykril
Copy link
Member

Veykril commented Jul 30, 2024

For dep cycles see #14167

@bors bors closed this as completed in 4feec4b Jul 30, 2024
@rust-lang rust-lang locked as resolved and limited conversation to collaborators Jul 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants