ra-multiplex icon indicating copy to clipboard operation
ra-multiplex copied to clipboard

expose rust-analyzer lint errors from invalid Cargo.toml

Open falcucci opened this issue 11 months ago • 6 comments

currently the pop-up is shown as a generic error Failed to load workspaces in case you type a wrong crate name, for example, which makes it confusing to understand.

A more detailed notification would be appreciated.

falcucci avatar Mar 16 '24 18:03 falcucci

thanks! I'd like to try it in a few editors to see if we won't need to be a bit smarter about buffering the input more than by lines. So we don't get multiple notification bubbles for one error message spread across multiple lines, which could hide each other and make the message hard to read.

pr2502 avatar Mar 17 '24 00:03 pr2502

I'm trying to recreate the error messages you quoted in https://github.com/pr2502/ra-multiplex/pull/60#issuecomment-1997152894 but I can't :thinking:

What editor are you using with ra-multiplex? There might be a capability it registers which helix does not for me. With the current rust-analyzer and logging notifications I got this in my logs:

ERROR instance{pid=19633}: stderr line=<timestamp> ERROR flycheck: Flycheck failed to run the following command: CommandHandle { program: "/usr/bin/cargo", arguments: ["check", "--workspace", "--message-format=json", "--manifest-path", "/home/max/code/ra-multiplex/Cargo.toml", "--all-targets"], current_dir: Some("/home/max/code/ra-multiplex") }
DEBUG instance{pid=19633}: server notification notif={"jsonrpc":"2.0","method":"$/progress","params":{"token":"rust-analyzer/flycheck/0","value":{"kind":"end"}}}
DEBUG instance{pid=19633}: server notification notif={"jsonrpc":"2.0","method":"window/showMessage","params":{"message":"cargo check failed to start: Cargo watcher failed, the command produced no valid metadata (exit code: ExitStatus(unix_wait_status(25856))):\n    Updating crates.io index\nerror: no matching package named `serde_jsonp` found\nlocation searched: registry `crates-io`\nrequired by package `ra-multiplex v0.2.2 (/home/max/code/ra-multiplex)`","type":2}}

I get a rather useless error in the stderr output of rust-analyzer but a very useful message with the window/showMessage method - in my case showing the stderr in the editor would not help at all.

What I might want to do, at least for my helix setup, is to allow ra-mulitplex to display notifications in system notifications via notify-send because helix apparently ignores window/showMessage notifications.

pr2502 avatar Mar 17 '24 12:03 pr2502

hm seems like rust-analyzer is using a different method to show up the message for you.

What editor are you using with ra-multiplex?

I am using neovim with coc.nvim and rust-analyzer at nightly.

notif: {"jsonrpc":"2.0","method":"$/progress","params":{"token":"rustAnalyzer/Fetching","value":{"kind":"end"}}}
notif: {"jsonrpc":"2.0","method":"experimental/serverStatus","params":{"health":"error","message":"Failed to load workspaces.","quiescent":false}}
notif: {"jsonrpc":"2.0","method":"$/progress","params":{"token":"rustAnalyzer/Fetching","value":{"cancellable":false,"kind":"begin","title":"Fetching"}}}
notif: {"jsonrpc":"2.0","method":"$/progress","params":{"token":"rustAnalyzer/Fetching","value":{"cancellable":false,"kind":"report","message":"metadata"}}}
ERROR instance{pid=63552}: stderr line=2024-03-17T14:02:21.999612Z ERROR rust_analyzer::main_loop: FetchWorkspaceError:
ERROR instance{pid=63552}: stderr line=rust-analyzer failed to load workspace: Failed to load the project at /Users/falcucci/neovide/Cargo.toml: Failed to read Cargo metadata from Cargo.toml file /Users/falcucci/neovide/Cargo.toml, Some(Version { major: 1, minor: 78, patch: 0, pre: Prerelease("nightly") }): Failed to run `cd "/Users/falcucci/neovide" && RUSTUP_TOOLCHAIN="/Users/falcucci/.rustup/toolchains/nightly-aarch64-apple-darwin" "/Users/falcucci/.cargo/bin/cargo" "metadata" "--format-version" "1" "--manifest-path" "/Users/falcucci/neovide/Cargo.toml" "--filter-platform" "aarch64-apple-darwin"`: `cargo metadata` exited with an error:     Updating crates.io index
ERROR instance{pid=63552}: stderr line=error: no matching package named `anyhow2` found
ERROR instance{pid=63552}: stderr line=location searched: registry `crates-io`
ERROR instance{pid=63552}: stderr line=required by package `neovide v0.12.2 (/Users/falcucci/neovide)`
ERROR instance{pid=63552}: stderr line=
ERROR instance{pid=63552}: stderr line=
notif: {"jsonrpc":"2.0","method":"$/progress","params":{"token":"rustAnalyzer/Fetching","value":{"kind":"end"}}}
notif: {"jsonrpc":"2.0","method":"experimental/serverStatus","params":{"health":"error","message":"Failed to load workspaces.","quiescent":true}}

as you can see it uses the "experimental/serverStatus" method here, yours has the ideal info message tho 😐

and in my case yes, the only way I could see more details in the message popup was notifying our stderr. It would be nice if I could filter the most useful one tho.

which rust-analyzer version are you using in helix?

falcucci avatar Mar 17 '24 14:03 falcucci

I'm using rust-analyzer shipped by rustup

[language-server.rust-analyzer]
command = "/home/max/.cargo/bin/ra-multiplex"
args = ["client", "--server-path", "/usr/lib/rustup/bin/rust-analyzer"]

Which through rustup then launches /home/max/.rustup/toolchains/nightly-x86_64-unknown-linux/gnu/bin/rust-analyzer.

$ /usr/lib/rustup/bin/rust-analyzer --version
rust-analyzer 1.78.0-nightly (766bdce 2024-03-16)

pr2502 avatar Mar 17 '24 15:03 pr2502

@pr2502 that's super weird, I have the same rust-analyzer version. I also tried to reinstall just to make sure but it still uses "experimental/serverStatus" here.

It's important to note that zed editor have done something similar using the "experimental/serverStatus" aswell at https://github.com/zed-industries/zed/pull/8356/files which makes me think that it maybe varies from editor to editor? 👀

falcucci avatar Mar 17 '24 22:03 falcucci

or we are missing something we didn't notice still

falcucci avatar Mar 17 '24 22:03 falcucci