Stream: t-compiler/wg-rls-2.0

Topic: Multi-workspace support


Dirkjan Ochtman (Nov 21 2019 at 15:09, on Zulip):

I'm trying to dig into https://github.com/rust-analyzer/rust-analyzer/issues/2202 a little bit

Dirkjan Ochtman (Nov 21 2019 at 15:10, on Zulip):

but adding println!() calls in the ra_lsp_server don't show up anywhere as far as I can see

Dirkjan Ochtman (Nov 21 2019 at 15:10, on Zulip):

neither do log::error!() messages

Dirkjan Ochtman (Nov 21 2019 at 15:10, on Zulip):

any hint on how I could debug this thing?

Laurențiu Nicola (Nov 21 2019 at 15:14, on Zulip):

You can try https://github.com/rust-analyzer/rust-analyzer/tree/master/docs/dev#logging

Dirkjan Ochtman (Nov 21 2019 at 15:20, on Zulip):

even when running env RUST_LOG=gen_lsp_server=trace, I don't see anything show up in the "Rust Analyzer Language Server Trace" tab

Jeremy Kolb (Nov 21 2019 at 15:28, on Zulip):

Did you check the box in the vscode settings?

Jeremy Kolb (Nov 21 2019 at 15:29, on Zulip):

Sorry.... not a box. It's a trace option

Dirkjan Ochtman (Nov 21 2019 at 15:29, on Zulip):

I did now and there is some output

Dirkjan Ochtman (Nov 21 2019 at 15:29, on Zulip):

but not anything I log or print from inside the server, as far as I can tell

Jeremy Kolb (Nov 21 2019 at 15:32, on Zulip):

It might be ra_lsp_server instead of gen_lsp_server now

Dirkjan Ochtman (Nov 21 2019 at 15:36, on Zulip):

sounds sensible, but I don't see it making a difference

Dirkjan Ochtman (Nov 21 2019 at 15:42, on Zulip):

ahhh, found it

Jeremy Kolb (Nov 21 2019 at 15:45, on Zulip):

?

Dirkjan Ochtman (Nov 21 2019 at 15:53, on Zulip):

there was a different tab called "Rust Analyzer Language Server"

Laurențiu Nicola (Nov 21 2019 at 17:47, on Zulip):

Acutally I wanted to show you the RA_LOG_DIR, but I should have said that, sorry

Laurențiu Nicola (Nov 21 2019 at 17:47, on Zulip):

Glad you got it working though

matklad (Nov 21 2019 at 19:45, on Zulip):

Yeah, there are two tabs, one for client-side tracing of requests, on for server-side logging

matklad (Nov 21 2019 at 19:45, on Zulip):

note that we use stdout to communicate with the client, so println breaks things at the root

matklad (Nov 21 2019 at 19:45, on Zulip):

eprintln should be fine

Dirkjan Ochtman (Nov 21 2019 at 20:37, on Zulip):

@matklad the WorldState seems to be aware of all my workspaces just fine

Dirkjan Ochtman (Nov 21 2019 at 20:38, on Zulip):

but somehow compilation feedback only shows up for the first one in the list (which happens to also be the rootPath, although it seems that ends up not being used if multiple workspaces are defined)

Dirkjan Ochtman (Nov 21 2019 at 20:38, on Zulip):

any thoughts on where I should look next?

Matthias247 (Nov 21 2019 at 21:36, on Zulip):

note that we use stdout to communicate with the client, so println breaks things at the root

FWIW: This cost me about an hour to find out why nothing worked anymore after I tried to debug my RA changes. I had no idea it could have been related to the debug statements I added. Maybe some notification could emitted to prevent that. E.g. if VsCode detects malformed LSP requests, it shows up popup/notification or emits something in the extension log that says "Do not use println! for debugging. If you don't and still get this error, file a bug report".

matklad (Nov 22 2019 at 07:27, on Zulip):

@Dirkjan Ochtman interesting. The next thing to look at would probably be FileLoaderDelegate::relevant_crates -- this function should return a list of crates (compilation units), that can contain the given file. If that also returns a non-empty result, then the best thing to do would probably be to try to create a minimal reproduction, as I don't think there are more places where we can bisect the logic.

matklad (Nov 22 2019 at 07:28, on Zulip):

@Matthias247 ah, we actually even lock stdout in the server, so printlns just deadlock. Let's just override println in the server lib...

matklad (Nov 22 2019 at 07:34, on Zulip):

@Matthias247 https://github.com/rust-analyzer/rust-analyzer/pull/2349 should help in the future!

Matthias247 (Nov 22 2019 at 07:41, on Zulip):

Matthias247 https://github.com/rust-analyzer/rust-analyzer/pull/2349 should help in the future!

Does that help if you use println! in any of the other rust-analyzer crates? Like I tried in ra-project-model?

matklad (Nov 22 2019 at 07:43, on Zulip):

@Matthias247 nope, it doesn't :(

Last update: Dec 12 2019 at 00:55UTC