Sometimes RLS extension is stuck with errors or incomplete analysis and the only way to trigger it again is to restart the IDE.
Would be nice to have a possibility to do it manually, for example by clicking on the rls status bar item.
This should be a command. It would need some RLS support I think, but that should be quite simple (just need to trigger a full build - a 'cargo' build). In order to actually build, I think you'd need to 'touch' a file in the project - in fact, since we watch Cargo.toml and rebuild on change, touching that file might be enough to trigger a rebuild
@nrc , I tried to do
$ touch Cargo.toml
and
$ cargo build
Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs
But the RLS is still stuck in "working" position
@pftbest Keep in mind that artifacts from regular cargo check and the result of rls analysis are kept in separate folders, so these should be not related.
What worked for me:
But it may be possible that RLS will get stuck and the only way out is to reboot it. This happens occasionally when the tools used by the RLS crash, this still needs some hardening I believe. In this case it would, in fact, be handy to be able to reboot the server. @nrc do you think we could just shutdown the server and start it again, given the architecture? At least for now, in case the RLS will get in a weird state because of poison errors or similar.
@Xanewok Yeah, the RLS should be fine to reboot. I'm not sure exactly how to do this on the VSCode side, otherwise I would have done it already, but I don't think it is that hard. The only tricky thing is that when the RLS starts up, VSCode would need to send all the open files (or at least those that have been changed without a save), but iirc VSCode actually does that by default.
@Xanewok , yes, it works when everything is fine, but it doesn't work when RLS gets stuck. And it gets stuck very often, at least twice an hour for me.
vscode-rust extension actually has the "RLS: done" status button clickable for hard-restarting RLS, and it was really useful. Unfortunately, I just updated VSCode and RLS, and something broke, so it only stops RLS but doesn't restart it. I took this as a hint to finally check out this official extension and I'm surprised it still doesn't even have the functionality.
PS. Restart functionality is useful not only for crash mitigation, but also for reanalyzing some sorts of dependencies, like path="../third_party_crate" that one just modified, but which isn't a part of the workspace/project in general.
@albel727 yes I've tried using vscode-rust several times with this extension, but it hasn't worked each time, including lately when I tried again to try to restart it. And the former isn't maintained; perhaps it should be deprecated.
This is possible with the Ctrl+P > >Rust: Restart the RLS command inside the VSCode and generally the RLS should pick up changes that may affect the entire project (e.g. Cargo.lock, Cargo.toml changes).
Most helpful comment
vscode-rustextension actually has the "RLS: done" status button clickable for hard-restarting RLS, and it was really useful. Unfortunately, I just updated VSCode and RLS, and something broke, so it only stops RLS but doesn't restart it. I took this as a hint to finally check out this official extension and I'm surprised it still doesn't even have the functionality.