Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scala Import fails to add Scala SDK #1183

Closed
liucijus opened this issue Sep 20, 2019 · 12 comments
Closed

Scala Import fails to add Scala SDK #1183

liucijus opened this issue Sep 20, 2019 · 12 comments
Assignees
Labels
lang: scala Scala rules integration product: IntelliJ IntelliJ plugin type: bug

Comments

@liucijus
Copy link
Collaborator

liucijus commented Sep 20, 2019

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

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

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

@jin
Copy link
Member

jin commented Sep 25, 2019

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

@jin
Copy link
Member

jin commented Sep 25, 2019

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 5f03bde and cherry pick the revert into the next release?

@iirina
Copy link

iirina commented Sep 26, 2019

Thanks @jin for finding a fix!

@ittaiz
Copy link
Member

ittaiz commented Oct 3, 2019

@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

aradchykov pushed a commit to aradchykov/intellij that referenced this issue Oct 6, 2019
…j PR import bazelbuild#1202)

While `scala_library` / other Scala rules have `JavaInfo` as well, their Scala-specific data lives in the `scala` provider. Proritizing `JavaInfo` over `scala` causes the plugin to assume that there are no outputs, hence causing all Scala workspaces to fail to resolve ("No Scala SDK added") bazelbuild#1183

Instead, prioritize `kt` and `scala` providers over `JavaInfo`.

This wasn't an issue previously because we c[hecked for the legacy "java" provider first](bazelbuild@5f03bde), which Scala targets do not have, and the conditional successfully fell through.

This fixes bazelbuild#1183.

Closes bazelbuild#1202

PiperOrigin-RevId: 271236868
@iirina
Copy link

iirina commented Oct 7, 2019

My hunch is that the issue was caused by bazelbuild/bazel#8916 which is now fixed but not released yet.

@ittaiz
Copy link
Member

ittaiz commented Oct 12, 2019

@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.

@liucijus
Copy link
Collaborator Author

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()

@ittaiz
Copy link
Member

ittaiz commented Oct 17, 2019

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?

@jakemcc
Copy link

jakemcc commented Nov 20, 2019

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?

@ittaiz
Copy link
Member

ittaiz commented Jan 16, 2020

@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 5f03bde

@virusdave
Copy link

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

@theflippedbit
Copy link

I'm running into the Scala SDK being dropped on sync with the following versions:

IntelliJ IDEA 2021.3.2 (Ultimate Edition) Build #IU-213.6777.52
Bazel Plugin 2022.02.08.0.1-api-version-213
Bazel 4.2.1
Scala Rules for Bazel (https://github.com/bazelbuild/rules_scala) e7a948ad1948058a7a5ddfbd9d1629d6db839933

I have a prototype project where these versions work fine and don't drop the SDK setting on a sync, but in a much larger project where it is being dropped. Any suggestions on what else I could look into?

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lang: scala Scala rules integration product: IntelliJ IntelliJ plugin type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants