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

Building on v1.5.0-alpha-2 fails on Windows #492

Closed
odracirnumira opened this issue Feb 21, 2021 · 3 comments · Fixed by #521 or #569
Closed

Building on v1.5.0-alpha-2 fails on Windows #492

odracirnumira opened this issue Feb 21, 2021 · 3 comments · Fixed by #521 or #569

Comments

@odracirnumira
Copy link

odracirnumira commented Feb 21, 2021

I've been trying to use v1.5.0-alpha-2 and compilation of any Kotlin code fails with:

Exception in thread "main" java.lang.ExceptionInInitializerError
        at io.bazel.kotlin.builder.KotlinBuilderMain.main(KotlinBuilderMain.java:26)
Caused by: java.lang.IllegalStateException: runfile manifest C:/users/odrac/_bazel_odrac/vpohbkhb/execroot/__main__/bazel-out/host/bin/external/io_bazel_rules_kotlin/src/main/kotlin/builder.exe.runfiles/MANIFEST did not contain path mapping for external/com_github_jetbrains_kotlin/lib/jvm-abi-gen.jar

I've attached a simple repro project (BUILD, WORKSPACE, and Main.kt files), which look like this:

WORKSPACE

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

RULES_KOTLIN_VERSION = "v1.5.0-alpha-2"
RULES_KOTLIN_SHA = "6194a864280e1989b6d8118a4aee03bb50edeeae4076e5bc30eef8a98dcd4f07"

http_archive(
    name = "io_bazel_rules_kotlin",
    urls = ["https://github.com/bazelbuild/rules_kotlin/releases/download/%s/rules_kotlin_release.tgz" % RULES_KOTLIN_VERSION],
    sha256 = RULES_KOTLIN_SHA,
)

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

BUILD

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

kt_jvm_binary(
    name = "main",
    srcs = ["Main.kt"],
    main_class = "foo.bar.MainKt",
    deps = [
    ]
)

Main.kt

package foo.bar

fun main() {
    println("Hello world")
}

Running bazel build //:main or bazel run //:main fails with the aforementioned exception (I've also attached the full stack trace since the error is a bit larger).

Note that this also reproduces with v1.5.0-alpha-3.

BugReproProject.zip
Stacktrace.txt

@jesseschalken
Copy link
Contributor

Also fails on v1.5.0-alpha-1 with the same error.

@jesseschalken
Copy link
Contributor

jesseschalken commented Mar 25, 2021

As a guess, I think @com_github_jetbrains_kotlin//:jvm-abi-gen needs to be added to deps (or runtime_deps, not sure) here:

java_library(
name = "builder",
srcs = glob(["*.java"]),
visibility = ["//src:__subpackages__"],
runtime_deps = [
"@com_github_jetbrains_kotlin//:kotlin-stdlib-jdk7",
"@com_github_jetbrains_kotlin//:kotlin-stdlib-jdk8",
],
deps = [
"//src/main/kotlin/io/bazel/kotlin/builder/tasks",
"//src/main/kotlin/io/bazel/kotlin/builder/toolchain",
"//src/main/kotlin/io/bazel/kotlin/builder/utils",
"//src/main/protobuf:deps_java_proto",
"//src/main/protobuf:kotlin_model_java_proto",
"//src/main/protobuf:worker_protocol_java_proto",
"//src/main/kotlin/io/bazel/worker",
"//third_party:dagger",
"@com_github_jetbrains_kotlin//:annotations",
"@com_github_jetbrains_kotlin//:kotlin-stdlib",
"@kotlin_rules_maven//:javax_annotation_javax_annotation_api",
"@kotlin_rules_maven//:javax_inject_javax_inject",
],
)

which would reference the lib here:

kt_jvm_import(
name = "jvm-abi-gen",
jar = "lib/jvm-abi-gen.jar",
)

@fmeum
Copy link
Contributor

fmeum commented Aug 10, 2021

This is still failing for me on Windows with v1.5.0-alpha-3:

---8<---8<--- Start of log, file at C:/users/runneradmin/_bazel_runneradmin/2gbstkcc/bazel-workers/worker-3-KotlinCompile.log ---8<---8<---
Exception in thread "main" java.lang.ExceptionInInitializerError
	at io.bazel.kotlin.builder.cmd.Build$main$1.invoke(Build.kt:33)
	at io.bazel.kotlin.builder.cmd.Build$main$1.invoke(Build.kt:25)
	at io.bazel.worker.Worker$Companion.from(Worker.kt:35)
	at io.bazel.kotlin.builder.cmd.Build.main(Build.kt:29)
Caused by: java.lang.IllegalStateException: runfile manifest C:/users/runneradmin/_bazel_runneradmin/2gbstkcc/execroot/jazzer/bazel-out/host/bin/external/io_bazel_rules_kotlin/src/main/kotlin/build.exe.runfiles/MANIFEST did not contain path mapping for external/com_github_jetbrains_kotlin/lib/jvm-abi-gen.jar
	at io.bazel.kotlin.builder.utils.BazelRunFiles.resolveVerified(BazelUtils.kt:74)
	at io.bazel.kotlin.builder.toolchain.KotlinToolchain.<clinit>(KotlinToolchain.kt:60)
	... 4 more
---8<---8<--- End of log ---8<---8<---

It is fixed by the following patch, which I will submit as a PR:

--- src/main/kotlin/BUILD.bazel
+++ src/main/kotlin/BUILD.bazel
@@ -41,6 +41,7 @@
         ":skip-code-gen",
         "//src/main/kotlin/io/bazel/kotlin/compiler",
         "@com_github_jetbrains_kotlin//:lib/kotlin-compiler.jar",
+        "@com_github_jetbrains_kotlin//:lib/jvm-abi-gen.jar",
     ],
     main_class = "io.bazel.kotlin.builder.cmd.Build",
     visibility = ["//visibility:public"],

fmeum added a commit to fmeum/rules_kotlin that referenced this issue Aug 10, 2021
fmeum added a commit to fmeum/rules_kotlin that referenced this issue Aug 11, 2021
cgruber pushed a commit that referenced this issue Sep 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants