-
Notifications
You must be signed in to change notification settings - Fork 278
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
Scalafmt fails with Build without the bytes #1525
Comments
Is this a Bazel bug or a rules_scala one? |
Added reproduction in https://github.com/gergelyfabian/bazel-scala-example/ (master branch):
|
Checking whether this is a bazel issue:
|
Trick is that I had to turn off using a java toolchain and remotejdk_17 first, as remotejdk_17 does not work for some commits as bisecting. |
That is:
|
Thank you, bazelisk, indeed this seems to be the answer.
|
Forming the question again, scalafmt internal outputs not working with "build without the bytes" is a bug of Bazel or rules_scala? |
"Using a remote cache or even a disk cache will make actions "remote" from this point of view." (thanks @fmeum) In my case, disk cache is enabled. |
The information I received on the Bazel slack was that if rules_scala emitted correct information ( |
@gergelyfabian could you check if anything might be missing here: https://github.com/bazelbuild/rules_scala/blob/master/scala/private/phases/phase_scalafmt.bzl#L18? |
The current state where I'm at is this.
Then, we go to the phase_default_info, and runfiles properly includes the But, when api.bzl runs (https://github.com/bazelbuild/rules_scala/blob/master/scala/private/phases/api.bzl#L85) it does not get the |
Debug output like this:
Debugging code is here: https://github.com/gergelyfabian/rules_scala/tree/bazel-7.0-scalafmt-bug |
Btw. the following command also fails for Bazel 6.4.0: |
Maybe the necessary information is lost here:
Added these debug lines just before the return statement in phase_default_info.bzl. Prints:
|
I'm wondering whether |
I've added some more debugging and I think api.bzl is returning proper DefaultInfo for the rules. Having https://github.com/bazelbuild/rules_scala/blob/master/scala/private/phases/api.bzl#L91 (that sets up the final rule output): I have added a debug line just before that:
This prints for me:
So, this includes the files that I think should be there, specifically: So I think the rule definition returns a DefaultInfo that contains what is necessary. Even though it's under default_runfiles.files. Is the DefaultInfo constructed by rules_scala faulty, or it's a Bazel bug? Updated debugging code in https://github.com/gergelyfabian/rules_scala/tree/bazel-7.0-scalafmt-bug. |
Opened Bazel bug: bazelbuild/bazel#20099 |
Quoting a response from the bazel issue:
Originally posted by @tjgq in bazelbuild/bazel#20099 (comment) |
Hey @gergelyfabian I'm curious if you've tried this with https://github.com/aspect-build/rules_lint |
I experienced some issues when trying to apply the latest version of rules_lint, and also it seems it's ~3 times slower on our monorepo than running rules_scala's scalafmt (with parallelized targets), so I think we'll be staying with that. |
When running a target like this:
I receive:
It seems the action responsible for creating this file executes (I have tested disabling writing the output there, but then obviously it fails due to not generating an output), but at a later step the action running scalafmt from the manifest cannot see the scalafmt outputs.
One difference I can see in the bazel-bin folder between Bazel 6.4.0 and Bazel 7.0rc2 (after running
bazel run //utils/smth:library.format-test
):The text was updated successfully, but these errors were encountered: