intellij: " File->Open" does not detect that a project is a bazel project
To help people get started quickly, it’s not uncommon for people to check in .ijwb/.bazelproject
files. However, once this is done, there’s no way to actually use this:
- “Bazel import project” will complain that the file already exists
- “File->Open…” doesn’t detect that this is a bazel project, so the plugin isn’t enabled
- “File->Import Project” doesn’t list “Bazel” as an external model.
It seems clunky to check in the project config to a different location and then tell people to point to that.
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 10
- Comments: 23 (4 by maintainers)
I’ve struggled with putting IDE configuration for Bazel projects under version control as well. I’ll get into my workarounds, although I don’t think they’re great.
The Exploring the IntelliJ Bazel Plugin’s Sync Process blog post mentioned above has this to say:
For the
.bazelproject
file, it’s somewhat reasonable to put that somewhere else such asijwb/ijwb.bazelproject
, similar to this repo.For the IntelliJ configuration files, though, I don’t believe anything under
.idea/
is going to be used, only directories such as.ijwb/.idea/
. I have two approaches, neither of which I think is ideal:1. Keep IDEA config in
.ijwb/.idea/
and check that into version controlYou have to instruct people setting themselves up on a repo the first time to
rm -rf .ijwb/
(!!!)ijwb/ijwb.bazelproject
git checkout .ijwb/
to restore the deleted config files you’ve kept under version controlThe upshot is that once they’re set up their IDE configuration will stay consistent with upstream.
2. Put IDEA config somewhere else like
.idea/
Again you need to provide some user instructions:
git ls-files .idea | while read -r file; do mkdir -p .ijwb/$(dirname $file) && cp $file .ijwb/$file; done
(or put that in a script and have them run it)While at least you aren’t telling users to delete a directory, the downside of this approach is that the configuration under
.ijwb/.idea/
won’t stay in sync with upstream, so configuration can drift.All in all, I think approach 1 is the most workable, but it’s obviously not ideal.
@mattgodbolt I’m working on a blogpost to demystify some of these: https://github.com/bazelbuild/bazel-blog/pull/200
We’ll probably surface this in documentation soon as well.