hey folks, the HEAD is broken for `rules_kotlin` f...
# bazel
p
hey folks, the HEAD is broken for
rules_kotlin
for many folks. it’d be great if we could unblock it so teams can upgrade to kotlin 1.5 https://github.com/bazelbuild/rules_kotlin
m
The last release cut a few weeks ago should work with Kotlin 1.5.21 afaik
p
We tried it but it doesn't work for us :( There are multiple folks who aren't able to use it because of the cyclic dependency error in bazel
m
Did you try the release archive? What's the error you're facing?
p
This wasn't reported by me but we're seeing a similar error: https://github.com/bazelbuild/rules_kotlin/issues/602
m
I've got a very similar declaration in my repo and no problem with it - the only obvious difference is that I manually specify a
compiler_release
in the
kotlin_repositories
call, and a toolchain
Ha no sorry I'm not on the release... My bad
Let me try to update the the beta 4 see how that goes
Welp the beta 4 release archive has the same checksum as the one I had built locally so no difference here - it works fine here 😕
I'm wondering if passing a specific compiler release would work for you:
Copy code
kotlin_repositories(
    compiler_release = kotlinc_version(
        release = kotlin_compiler.version,
        sha256 = kotlin_compiler.sha,
    ),
)
For reference, the version and checksum I have for the compiler:
Copy code
version = "1.5.21",
    sha = "f3313afdd6abf1b8c75c6292f4e41f2dbafefc8f6c72762c7ba9b3daeef5da59",
p
Ok thanks. Will take a look at that tomorrow. A stable, workable new release would be great. We'd like to use ktlint and some other new changes that were shipped
m
That's been in the works for a bit afaik, but the compiler being an ever moving target, and the resources to work on this being quite thin, it's been consistently delayed by one more thing, from what I can see in the issues tracker...
p
i tried it but it requires a newer rules_kotlin version than the one we’re on. we had some issues with ECR records but i believe that’s fixed now (or there’s a workaround)
Still seeing this error:
Copy code
ERROR: Failed to load Starlark extension '@rkt_1_4//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.
 - @rkt_1_4
This could either mean you have to add the '@rkt_1_4' 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.
ERROR: cycles detected during target parsing
This our root BUILD.bazel
Copy code
load("@io_bazel_rules_kotlin//kotlin/internal:opts.bzl", "kt_javac_options", "kt_kotlinc_options")

# Currently blocked on <https://github.com/bazelbuild/rules_kotlin/issues/517>
kt_kotlinc_options(
    name = "brex_kotlinc_options",
    # This is necessary due to
    # <https://github.com/micronaut-projects/micronaut-core/blob/b581ba6b2a16da720b91ff4e60541f964aafd082/src/main/docs/guide/languageSupport/java/retainparameternames.adoc>
    java_parameters = True,
)

kt_javac_options(
    name = "brex_javac_options",
)

load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "define_kt_toolchain")

define_kt_toolchain(
    name = "kotlin_toolchain",
    api_version = "1.4",
    javac_options = ":brex_javac_options",
    jvm_target = "1.8",
    kotlinc_options = ":brex_kotlinc_options",
    language_version = "1.4",
)
and our root WORKSPACE
Copy code
# Begin kotlin section
load("@brex_rules_kotlin//:repos.bzl", "kotlin_repos")

kotlin_repos()

load("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps")

rules_jvm_external_deps()

load("@rules_jvm_external//:setup.bzl", "rules_jvm_external_setup")

rules_jvm_external_setup()

load("@brex_rules_kotlin//:deps.bzl", "add_kotlin")

add_kotlin()

load("//bazel:kotlin_third_party.bzl", "kotlin_deps")

kotlin_deps()

register_toolchains("//:kotlin_toolchain")

load("@brex_rules_kotlin//:post_maven.bzl", "post_maven_setup")

post_maven_setup()

# End kotlin section
Rest of the file is elided but i can share more context if useful