Intellij: Scala Import fails to add Scala SDK

Created on 20 Sep 2019  路  11Comments  路  Source: bazelbuild/intellij

IntelliJ IDEA 2019.2.2 (Community Edition)
Bazel Plugin: source build

Sync fails attaching Scala SDK to module. Can be reproduced since 5f03bde0f02f5d1693a4567dc129230420a30372

Repo to reproduce: https://github.com/liucijus/bazel-scala-example

IntelliJ scala bug

Most helpful comment

With the bazel plugin 2019.10.29.0.2 and intellij ultimate 2019.2.4 I'm still seeing the Scala SDK get dropped whenever a sync happens. Any ideas?

All 11 comments

cc @iirina this change caused all Scala workspaces to stop resolving code. Do you know what may be the root cause here?

cc @brendandouglas this is pretty serious as it causes all Scala workspaces to complete stop resolving. In the mean time while we find a mitigation (either the plugin or rules_scala), shall we revert the 5f03bde0f02f5d1693a4567dc129230420a30372 and cherry pick the revert into the next release?

Thanks @jin for finding a fix!

@jin @iirina was this due to a bug in JavaInfo? If so any idea what's the bug? Ideally we'd like scala to use the regular JavaInfo and not a custom attribute

My hunch is that the issue was caused by https://github.com/bazelbuild/bazel/issues/8916 which is now fixed but not released yet.

@liucijus I tried reproducing the issue by manually editing the intellij_info_impl.bzl file to the order pre the fix but couldn't reproduce it. Can you reproduce locally? I was trying to see if the fixed Bazel version indeed fixes it but after 2-3 hours of failing to reproduce I stopped.

I can't run this fix without upgrading rules_scala version. But if I upgrade problem does not reproduce with older versions of bazel as well. For example, with rules_scala_version = "b2273e7a90eac81132c9cdb8b2ca05fdbba74e46" problem does not reproduce with Bazel 0.29.0.
If I don't upgrade Scala rules, and run with Bazel 1.0.0:

ERROR: /home/vaidas/.cache/bazel/_bazel_vaidas/f790999ae9f6a398f2727c584e8fa64d/external/io_bazel_rules_scala_scala_reflect/BUILD:9:1: in scala_import rule @io_bazel_rules_scala_scala_reflect//:io_bazel_rules_scala_scala_reflect: 
Traceback (most recent call last):
    File "/home/vaidas/.cache/bazel/_bazel_vaidas/f790999ae9f6a398f2727c584e8fa64d/external/io_bazel_rules_scala_scala_reflect/BUILD", line 9
        scala_import(name = 'io_bazel_rules_scala_scala_reflect')
    File "/home/vaidas/.cache/bazel/_bazel_vaidas/f790999ae9f6a398f2727c584e8fa64d/external/io_bazel_rules_scala/scala/scala_import.bzl", line 27, in _scala_import_impl
        struct(scala = struct(outputs = struct(...)), ...)])
    File "/home/vaidas/.cache/bazel/_bazel_vaidas/f790999ae9f6a398f2727c584e8fa64d/external/io_bazel_rules_scala/scala/scala_import.bzl", line 32, in struct
        _create_provider(current_jars, transitive_runtime_j..., <5 more arguments>)
    File "/home/vaidas/.cache/bazel/_bazel_vaidas/f790999ae9f6a398f2727c584e8fa64d/external/io_bazel_rules_scala/scala/scala_import.bzl", line 73, in _create_provider
        java_common.create_provider(use_ijar = False, compile_time_jar...]), <3 more arguments>)
type 'java_common' has no method create_provider()

That's strange because I think this reproduced internally when we were on a relatively advanced version of rules_scala. What do you think we should do here?

With the bazel plugin 2019.10.29.0.2 and intellij ultimate 2019.2.4 I'm still seeing the Scala SDK get dropped whenever a sync happens. Any ideas?

@jakemcc usually valuable to also note which rules_scala version you're using and which bazel version you're using because unfortunately all 4 components need to be in sync.

@brendandouglas I just merged a change to rules_scala which drops the scala attribute since we wanted to move off of the legacy providers. I think you can try and re-apply https://github.com/bazelbuild/intellij/commit/5f03bde0f02f5d1693a4567dc129230420a30372

This happens every time to me with
IntelliJ IDEA 2019.3.5
Bazel plugin 2020.06.01.1.0
Bazel 3.2.0
HigherKindness rules_scala_annex (@ b772564a20eee9271068cfba55147191385343bd) https://github.com/higherkindness/rules_scala

Was this page helpful?
0 / 5 - 0 ratings