shuttle icon indicating copy to clipboard operation
shuttle copied to clipboard

[Bug]: cargo shuttle run in combination with rust-analyzer causes recompile pingpong

Open pogopaule opened this issue 1 year ago • 5 comments

What happened?

First of all, there is already an issue describing the same problem, but it has been closed. For me the problem is still present and the solution described there does not work since I don't use VSCode, but Neovim.

The Problem

  1. Launch Neovim (with lsp configured for rust-analyzer)
  2. Open one of the example shuttle projects and let rust-analyzer finish
  3. Run cargo shuttle run in another terminal -> triggers a partial rebuild
  4. Go back to Neovim and make a tiny change, e.g. change a string -> triggers a partial rebuild by rust-analyzer
  5. Goto 3.

If I do a cargo build in step 3 the partial rebuild does not occur. Only a cargo shuttle run does so.

I assume that cargo shuttle run and rust-analyzer launched by neovim somehow partially invalidate each others caches (see Links section below). I don't understand both tools well enough to debug the issue on my own.

My setup

  • NixOS 22.11
  • Neovim 0.8.3 with rust-analyzer version 2023-03-27

Links

Here are a few links to resources pointing into a similar direction, but didn't help me:

  • https://github.com/rust-lang/rust-analyzer/issues/6136
  • https://github.com/rust-lang/rust-analyzer/issues/12714
  • https://news.ycombinator.com/item?id=29571792

Version

0.13.0

Which operating systems are you seeing the problem on?

Linux

Which CPU architectures are you seeing the problem on?

x86_64

Relevant log output

No response

Duplicate declaration

  • [X] I have searched the issues and there are none like this.

pogopaule avatar Apr 01 '23 16:04 pogopaule

Looks like these lines are responsible for the problem. Removing them resolves the issue... I'll do more tests and post my findings here.

pogopaule avatar Apr 01 '23 16:04 pogopaule

Which version of rust are you on? We have an issue where if the users rustc/cargo is greater than the version we use in cargo-shuttle (which uses the cargo library`) the project will be recompiled fully for any change. We are currently on 1.68 though, but perhaps this will also occur if you are on 1.68.1/1.68.2?

oddgrd avatar Apr 03 '23 07:04 oddgrd

❯ rustc --version
rustc 1.67.1 (d5a82bbd2 2023-02-07) (built from a source tarball)

❯ cargo --version
cargo 1.67.0

In my case the project does not seem to get recompiled fully, but only partially. Yet it takes too much time (~2min) for a fluent dev workflow.

pogopaule avatar Apr 03 '23 07:04 pogopaule

Hm, that should work. :thinking: You could try using 1.68, but I don't believe having an older version should be an issue.

oddgrd avatar Apr 03 '23 07:04 oddgrd

But so far it looks good. My suspicion that the removal of clippy fixed the problem is growing stronger.

The checkOnSave option also comes up in similar issues (like the ones I linked above) a lot...

pogopaule avatar Apr 03 '23 07:04 pogopaule