bazelbuild / rules_kotlin

Bazel rules for Kotlin
Apache License 2.0
332 stars 206 forks source link

kotlin compiler and ksp repositories fail to initialize on windows #1097

Closed ydynnikov closed 9 months ago

ydynnikov commented 9 months ago

Reproducible both on our repo with bazel 7.0.0 (using bzlmod) and when I do fresh checkout of this repository on tag v1.9.0

Platform: Windows 11

bazel build //... fails with errors looking like

ERROR: C:/users/user/_bazel_user/7vi7p7qd/external/rules_kotlin~1.9.0/kotlin/compiler/BUILD.bazel:23:17: no such target '@@rules_kotlin~1.9.0~rules_kotlin_extensions~com_github_google_ksp//:symbol-processing-cmdline.jar': target 'symbol-processing-cmdline.jar' not declared in package '' defined by C:/users/user/_bazel_user/7vi7p7qd/external/rules_kotlin~1.9.0~rules_kotlin_extensions~com_github_google_ksp/BUILD.bazel (Tip: use `query "@@rules_kotlin~1.9.0~rules_kotlin_extensions~com_github_google_ksp//:*"` to see all the targets in that package) and referenced by '@@rules_kotlin~1.9.0//kotlin/compiler:symbol-processing-cmdline'

What I've found by log-debugging (I don't know how to debug starlark in any other way yet :-( ):

restingbull commented 9 months ago

This is for bzlmod, correct?

ydynnikov commented 9 months ago

@restingbull hi, yes, it's for bzlmod. I've already dug deeper and found that it was due to the fact that when you use terminal in IDEA, it's powershell by default. When launching bazel from msys shell there is no problem

Worth noting that the problem could be visible earlier: repository_ctx.execute returns status struct that could be checked for failures. In my case failure was something like "CreateProcessW(...): mv is not recognized as a program"

ydynnikov commented 9 months ago

As for logging - it might be related to the fact that repository didn't fail to initialize, and between runs I only did bazel clean, not bazel clean --expunge

(I'm new to bazel, so I might not understand simple things yet)

ydynnikov commented 9 months ago

@restingbull hi, I've managed to get this working both in msys2 and in powershell

For powershell you need mv.exe to be exposed to powershell, so putting msys's /usr/bin to PATH worked

There is another problem with running tests, but it deserves its own ticket