google/j2cl

io_bazel_rules_kotlin_configured

lemito opened this issue · 4 comments

Describe the bug
When building the example application, j2cl requires @io_bazel_rules_kotlin_configured, but when installing rules_kotlin there is another error directly related to @rules_kotlin
Error in the console:

ERROR: Failed to load Starlark extension '@io_bazel_rules_kotlin_configured//jvm:opts.bzl'.
Cycle in the workspace file detected. This indicates that a repository is used prior to being defined.
The following chain of repository dependencies lead to the missing definition.
 - @io_bazel_rules_kotlin_configured
This could either mean you have to add the '@io_bazel_rules_kotlin_configured' repository with a statement like `http_archive` in your WORKSPACE file (note that transitive dependencies are not added automatically), or move an existing definition earlier in your WORKSPACE file.

or

ERROR: Traceback (most recent call last):
        File "/home/lemit/my-monorepo/WORKSPACE", line 328, column 20, in <toplevel>
                kotlin_repositories()
        File "/home/lemit/.cache/bazel/_bazel_lemit/2c2f6942bcf82b2b975b5d4cf25d41ec/external/io_bazel_rules_kotlin/src/main/starlark/core/repositories/initialize.bzl", line 96, column 21, in kotlin_repositories
                rules_repository(
Error in repository_rule: invalid user-provided repo name '': valid names may contain only A-Z, a-z, 0-9, '-', '_', '.', and must start with a letter
ERROR: Error computing the main repository mapping: at /home/lemit/.cache/bazel/_bazel_lemit/2c2f6942bcf82b2b975b5d4cf25d41ec/external/io_bazel_rules_kotlin/kotlin/core.bzl:2:5: at /home/lemit/.cache/bazel/_bazel_lemit/2c2f6942bcf82b2b975b5d4cf25d41ec/external/io_bazel_rules_kotlin/kotlin/internal/opts.bzl:22:5: Encountered error while reading extension file 'jvm/opts.bzl': no such package '@io_bazel_rules_kotlin_configured//jvm': error loading package 'external': Could not load //external package

To Reproduce
The code is taken entirely from the helloworld repository and is used without the slightest change

Bazel version

Bazelisk version: v1.13.2
Build label: 6.1.1
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Wed Mar 15 15:44:56 2023 (1678895096)
Build timestamp: 1678895096
Build timestamp as int: 1678895096

Expected behavior
Expected the application to build

gkdn commented

The helloworld also has a bazelversion file that pins the supported version and we have CI setup that validates this is working untouched. So it should be something in your setup.
Possible scenarios that I can think of:

  1. Bazel version that you are using is 6.1.1, it might be possible that rules_kotlin version that we are using might have incompatibility with that. We are currently only testing with Bazel 5.x.
  2. You might have a more recent rules_kotlin that overrides the one from J2CL repo.

No, I've tried it on an older version of bazel as well, as I use bazelisk and the version is downloaded from just the bazelversion file.

gkdn commented

I can't see what is going on from your provided information.

I can tell that this is not happening in a clean repo so there should be something in your setup or the way you run it contributing to the problem here.

Can you try in a clean repo? If it doesn't work, could you share your steps for running it?
If it works, could you compare that with your own repo and see what is different?

Hello

Tried it for the 5th time and... it worked. Of course, I tried it on a clean helloworld, but no error occurred.
I will close this issue, because technically the problem is solved. If it occurs again, I will try to describe each step in more detail based on your questions and points and reopen the issue.

Thanks for solving the problem :)