Replies: 3 comments 11 replies
-
Does this happen for any project or only for a specific one? One thing you could try doing is deleting the vscode workspace cache. |
Beta Was this translation helpful? Give feedback.
10 replies
-
We shouldn't quit that way, but there's a Cargo issue which causes it to show random errors when building after you switch git branches during a |
Beta Was this translation helpful? Give feedback.
0 replies
-
One more thing you can try is changing the file watcher to server |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've recently started having an issue with a particular Rust project of mine that I'm developing on multiple machines, that when I do a git pull (outside of VSCode, I'm doing it on the command line in a terminal), and then restart VSCode, Rust analyzer can't build the project, because it hasn't apparently noticed that the files have changed.
i.e. it will complain that a field is not public, despite the recent git pull adding the
pub
in front of it, and VSCode's view itself clearly showing thepub
in front of the field in question it's complaining (and underlining in red!) about.Running
cargo build
orcargo build --release
from the command line of the project directory (outside of VSCode) works perfectly, as the code itself is fine (after the git pull), so it seems pretty clear rust-analyzer is operating on stale information somehow about the state of my source files.This is happening on both machines (one MacOS, one Linux), and the MacOS one is definitely using the latest VSCode (Linux machine might be slightly behind), and relatively recent rust-analyzer.
I can't seem to fix this from within VSCode itself, i.e. running the
Reload Workspace
,Rebuild Build Dependencies
and stopping and restarting the server do absolutely nothing to fix this, and neither does completely killing VSCode and making sure the language server isn't still running.The log item doesn't show anything other than:
and I'm not sure if that's related or not, I can't see any other errors.
The only way I can find to clear this, is to close VSCode, and run
cargo clean
, and thencargo build
again, and then restart VSCode, and then rust analyzer will be okay with the code again, however, as mentioned above,cargo build
worked fine (correctly) without the need for theclean
, so it seems like an issue with VSCode or rust-analyzer.Even force-modifying one of the files it's incorrectly complaining about to add whitespace doesn't trigger it to fix itself, and the modified timestamps on the files look okay.
I'm not checking any VSCode stuff (even launch.json) into git, so it only has Cargo.* and my .rs files.
Is there any way to try and work out why this is happening in terms of logs, or verbose options?
I notice previous Github issues regarding this which have been closed due to I guess it being sporadic for people in the past, but it's been persistently happening to me for a while now.
Beta Was this translation helpful? Give feedback.
All reactions