-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to clean up the cache? #16236
Comments
Did you already try reloading/restarting your editor? There could still be some actual issue but for me that "fixed" lots of stuff. (Mostly related to proc macros where this is intended) |
There is no cache, you might have edited Cargo's copy of B (under |
Thanks for you answers 😄
Of course, this hasn't change anything for me.
I don't see how it could behave the way it does without some cache somewhere. It defenitely remember the old code.
I tried to do |
|
Didn't work 😢 |
Does |
Does not seem to work either :/ |
You're on your own then. But remember that:
Also, you might want to check if you're using the workspace version of B, or if you're pulling it from crates.io. |
A and B are custom packages not pushed to crates.io. However if the commit sha1 is saved to Is it safe to remove the |
It will be created again, with the latest available versions. Keep the old one as a backup. |
Doesn't work though... |
Can you show us your Cargo.toml files (or relevant excerpts)? |
I can show you a resume. File architecture ->
[workspace]
resolver = "2"
members = [
"A",
"folder1/B",
"folder1/C",
]
exclude = ["D"]
[workspace.dependencies]
libLib = "=0.x.x"
[package]
name = "A"
version = "1.0.0"
authors = ["Me"]
edition = "2018"
description = "Main program"
homepage = "no_homepage"
[dependencies]
libLib .workspace = true
# Internal dependencies
B = { path = "../folder1/B/" }
C = { path = "../folder1/C/" }
[package]
name = "B"
version = "0.1.0"
authors = ["Me"]
edition = "2018"
[dependencies]
libLib.workspace = true
# Internal dependencies
C = { path = "../C/" }
[package]
name = "C"
version = "0.1.0"
edition = "2021"
[dependencies]
libLib.workspace = true Don't know if its related or not but the What happened is that the package B changed with a field added to a struct and the package A was updated accordingly. The code compiles but vscode shows an error in package A that says the field is missing. Note: In the B changes, I did not change the version of the B package. When change it to, let's say, "0.1.1", vscode does not report the issue anymore. But if I change it back, the error is shown again. |
On a good note: When I change all the At least this gives me a workaround if it happens again 😄 |
I've been seeing a very similar error, involving a path to a git reposity in my Again, the project builds fine with the most recent changes in git, and in the above example, if I select the highlighed Reopening VSCode didn't work. Uninstalling and reinstalling rust-analyzer didn't work. I'm on Ubuntu 22.04, VSCode 1.85.1, rust-analyzer VSCode extension v0.3.1807 |
Spoke too soon, |
rust-analyzer doesn't cache rustc errors to the degree that you're describing. If anything, Cargo's caches might be messed up—have you run a Cargo clean? |
Thank you @davidbarsky for following up, I just ran |
Seems like it comes from the A collegue of mine had the issue and fixed it by removing the Next time I get this issue I'll try running |
Maybe this should be a separate issue I should open, but consider this use-case: Mono-ish repo where you have separate Rust projects mixed with some Python projects:
In this case, no matter how many times I cd into However, if I instead open VS Code just for the following folder:
It instantly resolves squiggly red lines for a struct that it was previously outdated on / didn't recognize latest public fields for. But if I switch back to opening So can rust-analyzer support these sorts of hybrid project structures with various modules located in deeper subfolders? |
About my previous comment: I swear at one point it was no issue opening a mono-repo with deeper-nested Rust modules... So maybe this is a bug? I am on the latest prerelease FYI |
This behavior happened to me again and a I do have python code, and even rust to python binding in one package, so maybe it is related. I do want to open the all project in VS code though, it is much more practical to me. As this happens not very often and I have a "solution" to fix this, it does not bother me as much but still feel like a bug. Not being able to clean a state of rust analyzer seems like a feature missing though. |
Can't find it in the issue comments, what error do you get exactly? Is it a cargo error or a rust analyzer error? |
Also depending on the error is something maybe depending on the current working directory? Like a proc macro or something? Or potentially rust-analyzer somewhere uses it in the wrong way. Also if somebody could provide a reproduction example that would probably be great. Though I understand that's not always possible because of private code etc. |
The issue is that the the program compile fine (cargo build) but the rust analyzer extension on VS code shows errors, for instance a missing enum element. The problem is that it happens very rarely on a big and private repository so I can't get a minimal code to reproduce the issue. I don't think it is a big deal, however when that is happening, rust analyzer gets in a weird state that can't be cleared, or at least I didn't find how. The only trick I found to fix it is to change the edition of the individual internal packages of the workspace, and then change it back. Completely recloned our repo apparently worked for one of my collegue, but it is really not acceptable for me. I'd really like a way to totally clean the "cache" that hides somewhere, and therefore fix the issue when it happens. |
@mohe2015 I've caught the bug!
Problem Tree: root_folder: # vs code opens this folder, so rust-analyzer must appease A and B simultaneously
python_mod_a
python_mod_b
rust_mod_A
Cargo.toml # depends on C git branch
rust_mod_B
Cargo.toml # depends on ../A and D git branch
rust_mod_C # has not been cargo updated yet
Cargo.lock # depends on D git branch with older sha in lock file
rust_mod_D # rust-analyzer tries to appease A by referencing older commit sha due to C, but that conflicts with B
src
schema.rs # contains updated struct but rust-analyzer ignores it since C still pointing at prev commit So the bug occurs if you have other projects, that you're not even working on, that still have running |
I had this issue as well, and what @evbo says works. I deleted the |
I thought I had a cache issue and looked everywhere for the old reference. It turns out I had added a weird settings to rust-analyzer months ago and forgot about it. Another place to look if you are stuck... |
I'm on Ubuntu 22.04, using the rust-analyzer extenstion in a git-versionned workspace where a workspace package A depends on another B.
I made a change on B, adding a field to a struct, without changing the version in
cargo.toml
, the project builds correctly but the extension show an error.If I change the version of the B package, the extension is fixed, but when I go back to the previous version, it shows up again.
I tried to use "cargo clean" but it doesn't change anything.
Where is the cache for rust analyzer and how to clean it?
Thanks!
EDIT: forgot to mention I'm using VS code
The text was updated successfully, but these errors were encountered: