Skip to content

LSP :: invalid config value rust-analyzer #4768

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
3 tasks done
vikigenius opened this issue Apr 27, 2025 · 2 comments
Open
3 tasks done

LSP :: invalid config value rust-analyzer #4768

vikigenius opened this issue Apr 27, 2025 · 2 comments
Labels

Comments

@vikigenius
Copy link

vikigenius commented Apr 27, 2025

Thank you for the bug report

  • I am using the latest version of lsp-mode related packages.
  • I checked FAQ and Troubleshooting sections
  • You may also try reproduce the issue using clean environment using the following command: M-x lsp-start-plain

Bug description

Latest version of rust-analyzer produces warnings

LSP :: invalid config value:
/cargo/extraEnv: invalid type: sequence, expected a map;

Steps to reproduce

Install latest version of rust-analyzer and lsp-mode. Open a Rust project and see the warnings

Expected behavior

No warning messages

Which Language Server did you use?

rust-analyzer

OS

Linux

Anything else?

Possibly this type has changed on the server side

defcustom lsp-rust-analyzer-cargo-extra-env []
@vikigenius vikigenius added the bug label Apr 27, 2025
@miyabinomuratic
Copy link

cargo.extraEnv has been a map since its introduction (rust-lang/rust-analyzer@c407cc5). The definition in lsp-mode didn't match since then, but the mismatch was silently ignored. From rust-lang/rust-analyzer@46ce474, rust-analyzer started showing a warning message on configuration error, which we are seeing.

With the diff below, the definition for cargo.extraEnv should match and the warning message is not displayed anymore, but I'm not sure if this is a proper fix. Please check if this is OK.

--- a/clients/lsp-rust.el
+++ b/clients/lsp-rust.el
@@ -851,10 +851,10 @@ or JSON objects in `rust-project.json` format."
   :group 'lsp-rust-analyzer
   :package-version '(lsp-mode . "9.0.0"))
 
-(defcustom lsp-rust-analyzer-cargo-extra-env []
+(defcustom lsp-rust-analyzer-cargo-extra-env #s(hash-table)
   "Extra environment variables that will be set when running cargo, rustc or
 other commands within the workspace.  Useful for setting RUSTFLAGS."
-  :type 'lsp-string-vector
+  :type 'alist

@miyabinomuratic
Copy link

Looks like the patch is OK? I'll open a PR if no one objects.

miyabinomuratic added a commit to miyabinomuratic/lsp-mode that referenced this issue May 17, 2025
…lsp#4768)

In rust-analyzer, cargo.extraEnv has been a map since its
introduction (rust-lang/rust-analyzer@c407cc5). The definition in lsp-mode
hasn't matched since then, but the mismatch has been silently ignored. From
rust-lang/rust-analyzer@46ce474, rust-analyzer started showing a warning message
on configuration error which we are seeing.

With this change, the definition for cargo.extraEnv should match and the warning
message is not displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants