IntelliJ IDEA 2019.1.3 fails to resolve dependencies
See original GitHub issueTldr; “How do I reset ALL plugin state when things go wrong”.
I have been using the bazel plugin for IntelliJ 2019.1.3, bazel 0.25.2, and plugin version v2019.05.13.0.2.
Running bazel build //... always works and Sync project with BUILD files always completes successfully.
However, IntelliJ sometimes (sometimes but not always) fails to resolve dependencies like so:

This only happens with dependencies which are being downloaded as jars (not compiled from source) e.g. any maven dependencies.
(We are using the rules_jvm_external maven_install rule to download dependencies but this happens with other rules too.)
Although all these dependency jars show up in bazel-REPO_NAME/external/..., they are not appearing in the ‘External Libraries’ explorer area.
The .ijwb/.idea/libraries is not being populated with the correct xml entries.
Adding libraries manually through the Project Structure dialog (and pointing to the jar used by bazel) works fine and then the dependencies are resolved fine, but the plugin is unable to do this automatically.
This problem can often be fixed by just adding a comma or whitespace to the BUILD file which causes the plugin to retry the dependency resolution. Resetting this whitespace will cause the problem to reappear, seemingly due to some cacheing. I am looking for a way to reliably reset all the state used by the plugin so that it will retry the external libraries resolution without having to add random whitespace or commas to BUILD files. Things tried so far to no avail:
- File > Invalidate Caches / Restart
- Reinstalling plugin
- Bazel -> Sync -> Sync Project
- Deleting
.ijwband reimporting project
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:17 (4 by maintainers)

Top Related StackOverflow Question
I think I’m hitting a similar issue. External dependencies referenced through
maven_installdidn’t have the right jars in the project.Looking into Project Settings > Libraries, I noticed that the path to those binaries were incorrect.
Example from my windows machine: commons-lang3-3.9.jar was referencing a path that didn’t exist.
[Project Root]\external\maven\v1\https\repo1.maven.org\maven2\org\apache\commons\commons-lang3\3.9\commons-lang3-3.9.jarI noticed that
[Project Root]\externalshould have been[Project Root]\bazel-[projectname]\externalinstead.As a workaround, I created a symlink from
[Project Root]\externalto[Project Root]\bazel-[projectname]\externaland IntelliJ started working properly.HTH
Can we please re-open this issue? We are seeing frequent syncing issues that are only fixed when making trivial edits to
BUILDfiles. It seems the plugin needs to consider the package to be within the working set in order to link dependencies in Intellij.