'IntelliJ saying files unsynced after syncing with Bazel

Even after syncing with Bazel, the files are still displaying as "unsynced" in IntelliJ.

I've tried moving to a previous version of Bazel, but to no avail.

Any recommendations here?



Solution 1:[1]

Use Bazel > Sync > Sync Project with BUILD Files if it is enabled. enter image description here

Solution 2:[2]

You should try adding the file to git. Sometimes files highlighted in red, or files that say "(unsynced)" next to their name just need to be added to the git branch so that they turn green again.

Solution 3:[3]

As @Karthikeyan Vaithilingam mentioned in his comment above, I had to do File > Invalidate Caches / Restart... Only then, Bazel > Snyc > Sync Project with BUILD Files made the unsynced labels finally disappear.

Solution 4:[4]

If your file isn't reachable from the targets specified in the targets: section in .bazelproject file, then it'll show up as unsynced'

Open you .bazelproject file and in under targets: Specify the path to your file/directory, re sync your project , It should fix it.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 pamcevoy
Solution 2 kat
Solution 3 Irina S.
Solution 4 ajain