IntelliJ plugin for Bazel

828 views
Skip to first unread message

Dan Fabulich

unread,
Nov 24, 2016, 1:40:03 AM11/24/16
to bazel-discuss
I spent some time today trying out the IntelliJ plugin for Bazel and filed some bugs.


1) Can someone say a few words about why it only works on Linux? The plugin appears to be written entirely in Java. What's preventing it from working on macOS?

2) Is this bug my fault somehow? https://github.com/bazelbuild/intellij/issues/32 The plugin throws an exception every time I sync, making me worry that my other bugs are side-effects/dupes.

3) Is there a workaround for this bug? https://github.com/bazelbuild/intellij/issues/34 On the command line we use --script-path. Can we configure something similar in IntelliJ?

Thanks!

-Dan

Philipp Wollermann

unread,
Nov 24, 2016, 4:25:01 AM11/24/16
to Dan Fabulich, bazel-discuss, brendan...@google.com, to...@google.com

--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/6287c8d4-5caf-4ef2-ba05-cf346d1c0839%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dan Fabulich

unread,
Nov 24, 2016, 9:59:02 PM11/24/16
to Philipp Wollermann, bazel-discuss, brendan...@google.com, to...@google.com
I was able to workaround issue #32 by downgrading Intellij to 2016.2, but that didn't help with the other issues I filed. Issue #34 is a big deal for us.

Tom Lundell

unread,
Nov 25, 2016, 12:31:41 AM11/25/16
to Philipp Wollermann, Dan Fabulich, bazel-discuss, brendan...@google.com
On Thu, Nov 24, 2016 at 4:24 AM, Philipp Wollermann <phi...@google.com> wrote:

On Thu, Nov 24, 2016 at 7:40 AM Dan Fabulich <danfa...@gmail.com> wrote:
I spent some time today trying out the IntelliJ plugin for Bazel and filed some bugs.


1) Can someone say a few words about why it only works on Linux? The plugin appears to be written entirely in Java. What's preventing it from working on macOS?

Nothing except we need to actually do it. It's mostly a matter of setting up a Mac CI to guarantee that it works and will keep working.
 

2) Is this bug my fault somehow? https://github.com/bazelbuild/intellij/issues/32 The plugin throws an exception every time I sync, making me worry that my other bugs are side-effects/dupes.

We don't yet work with 2016.3. It was released a couple days ago and we lag behind by several weeks, possibly more.
 

3) Is there a workaround for this bug? https://github.com/bazelbuild/intellij/issues/34 On the command line we use --script-path. Can we configure something similar in IntelliJ?

Sounds like a problem that should be fixed in bazel. You can pass --script-path yourself can you not?
 

Thanks!

-Dan

--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discuss+unsubscribe@googlegroups.com.

Dan Fabulich

unread,
Nov 25, 2016, 1:31:32 AM11/25/16
to Tom Lundell, Philipp Wollermann, bazel-discuss, brendan...@google.com

3) Is there a workaround for this bug? https://github.com/bazelbuild/intellij/issues/34 On the command line we use --script-path. Can we configure something similar in IntelliJ?

Sounds like a problem that should be fixed in bazel. You can pass --script-path yourself can you not?

If I can do this, then I don't understand how.

When using --script-path, "bazel run" doesn't actually run anything; it just generates a script that will do what "bazel run" ordinarily would have done. (That's only useful because that script can be executed after "bazel run" has finished; it won't hold the global bazel lock.)

And so, of course, we can "bazel run" with --script-path and generate a script, but the point of running a Bazel command inside IntelliJ is to attach a debugger to the bazel-executed process, right? If "bazel run" generates a script, there's nothing to attach to.

(Well, I guess we could launch the script from the command line and then attach remotely from inside IntelliJ, but that's effectively like not having an IDE plugin at all.)

Does that make sense?

-Dan

Dan Fabulich

unread,
Nov 25, 2016, 1:34:42 AM11/25/16
to Tom Lundell, Philipp Wollermann, bazel-discuss, brendan...@google.com
To be even more explicit: what I would want is for the IntelliJ plugin to automatically/implicitly invoke "bazel run" with --script-path, and then run the script and attach a debugger to the spawned Java process.

Alternately, as a workaround, I'd like manual steps I can follow to create a Run Configuration that does what I just described. Is that possible?

-Dan

--
You received this message because you are subscribed to a topic in the Google Groups "bazel-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/bazel-discuss/k1Pgf62mSSo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/3C35AE67-41A6-4EEC-9451-8E8DC055878C%40gmail.com.

Dan Fabulich

unread,
Jan 4, 2017, 2:59:39 PM1/4/17
to bazel-discuss, to...@google.com, phi...@google.com, brendan...@google.com
Ahoy! I'm picking this thread back up again now that I'm back from holiday. I have a build environment set up with the Bazel IntelliJ plugin.

I'm still interested in fixing https://github.com/bazelbuild/intellij/issues/34 "Can't run two Bazel processes at once"

My first PR to fix https://github.com/bazelbuild/intellij/issues/32 didn't go so well because the source drop on github is out of date; #32 is already fixed on Google's side.

Has anybody done any work on issue #34? Is it safe for me to do so?

Would it be better for me to work on this by fixing the bug on the Bazel side, instead? https://github.com/bazelbuild/bazel/issues/2337 "Allow "bazel run" to release the lock after building but before launching"

In February, Damien seemed to think that fixing #2337 on Bazel's side would be difficult and would "take a while to land," but that was almost a year ago. Any progress? https://groups.google.com/d/msg/bazel-discuss/mS98nXz9PbY/YRzJ-TYwIQAJ

-Dan

Dan Fabulich

unread,
Jan 4, 2017, 6:15:31 PM1/4/17
to bazel-discuss, to...@google.com, phi...@google.com, brendan...@google.com
In a comment to #2337, katre marked it as a dupe of #532 (Alternatives to "Another Bazel command is running (pid = 12345). Waiting for it to complete...")

The problem is that there isn't a lock per se, it's built into how Bazel operates. It'd be far simpler to update IntelliJ to use --script_path than to have Bazel recognize which situations are safe to allow to commands to run, without a fundamental change to how Bazel is written.

Maybe y'all can help me understand this better, but I don't think I agree.

#532 is a very ambitious bug. It proposes attempting to identify when/how two builds could be run simultaneously, subtly teasing apart which parts of the build can run safely in parallel. (Perhaps just the analysis phase? And if the outputs are guaranteed not to overlap…?)

To fix #2337, I'm imagining that `bazel run` would always use --script_path; the client process would just ReleaseLock in blaze.cc when the build is done, and then invoke the --script_path script itself. I guess it's a bit hacky, but it's no hackier than running this bash script https://github.com/bazelbuild/bazel/blob/master/scripts/bazel-run.sh and IMO it wouldn't require a significant change in architecture.

Fixing the bug in the IntelliJ plugin might actually pretty tricky. IntelliJ's API says, "OK, it's time to Run! Go execute your process now." Implicitly, it's allowing us to run just one process; there may be a clever way to get it to launch a pre-run build and then launch a second process for debugging, and I'll investigate that, but it's not obviously a slam dunk. (I know almost nothing about Eclipse's API, but it sounds like we'd have a similar problem to fix there.)

So fixing it in the IDE may require some extremely hairy integration code, per IDE. (Will there be other IDEs/runtime environments to support in the future??) And at the end of all that, the bug in the CLI still won't be fixed.

Am I approaching this problem incorrectly? If I put together a PR for the "hacky" fix I'm proposing, is that something that the team would be willing to merge in?

-Dan

Ulf Adams

unread,
Jan 11, 2017, 3:29:46 AM1/11/17
to Dan Fabulich, bazel-discuss, Tom Lundell, Philipp Wollermann, Brendan Douglas
On Thu, Jan 5, 2017 at 12:15 AM, Dan Fabulich <danfa...@gmail.com> wrote:
In a comment to #2337, katre marked it as a dupe of #532 (Alternatives to "Another Bazel command is running (pid = 12345). Waiting for it to complete...")

The problem is that there isn't a lock per se, it's built into how Bazel operates. It'd be far simpler to update IntelliJ to use --script_path than to have Bazel recognize which situations are safe to allow to commands to run, without a fundamental change to how Bazel is written.

Maybe y'all can help me understand this better, but I don't think I agree.

#532 is a very ambitious bug. It proposes attempting to identify when/how two builds could be run simultaneously, subtly teasing apart which parts of the build can run safely in parallel. (Perhaps just the analysis phase? And if the outputs are guaranteed not to overlap…?)

To fix #2337, I'm imagining that `bazel run` would always use --script_path; the client process would just ReleaseLock in blaze.cc when the build is done, and then invoke the --script_path script itself. I guess it's a bit hacky, but it's no hackier than running this bash script https://github.com/bazelbuild/bazel/blob/master/scripts/bazel-run.sh and IMO it wouldn't require a significant change in architecture.

Fixing the bug in the IntelliJ plugin might actually pretty tricky. IntelliJ's API says, "OK, it's time to Run! Go execute your process now." Implicitly, it's allowing us to run just one process; there may be a clever way to get it to launch a pre-run build and then launch a second process for debugging, and I'll investigate that, but it's not obviously a slam dunk. (I know almost nothing about Eclipse's API, but it sounds like we'd have a similar problem to fix there.)

So fixing it in the IDE may require some extremely hairy integration code, per IDE. (Will there be other IDEs/runtime environments to support in the future??) And at the end of all that, the bug in the CLI still won't be fixed.

Am I approaching this problem incorrectly? If I put together a PR for the "hacky" fix I'm proposing, is that something that the team would be willing to merge in?

I added a comment to #2337 instead of replying here. In short, I think it needs to be done in the bazel client, and I wouldn't consider it hacky if it's done properly. :-)
 

-Dan

On Wednesday, January 4, 2017 at 11:59:39 AM UTC-8, Dan Fabulich wrote:
Ahoy! I'm picking this thread back up again now that I'm back from holiday. I have a build environment set up with the Bazel IntelliJ plugin.

I'm still interested in fixing https://github.com/bazelbuild/intellij/issues/34 "Can't run two Bazel processes at once"

My first PR to fix https://github.com/bazelbuild/intellij/issues/32 didn't go so well because the source drop on github is out of date; #32 is already fixed on Google's side.

Has anybody done any work on issue #34? Is it safe for me to do so?

Would it be better for me to work on this by fixing the bug on the Bazel side, instead? https://github.com/bazelbuild/bazel/issues/2337 "Allow "bazel run" to release the lock after building but before launching"

In February, Damien seemed to think that fixing #2337 on Bazel's side would be difficult and would "take a while to land," but that was almost a year ago. Any progress? https://groups.google.com/d/msg/bazel-discuss/mS98nXz9PbY/YRzJ-TYwIQAJ

-Dan

--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discuss+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages