rules_kotlin icon indicating copy to clipboard operation
rules_kotlin copied to clipboard

_ksp_compiler_plugin_repository_impl Fails on Windows

Open Poligun opened this issue 1 year ago • 7 comments

First of all I think we should check the exec_result at this line since it's quite common that mv would fail.

        result = repository_ctx.execute(args, quiet = False)
        if result.return_code != 0:
            fail("Failed to move jar: %s" % result.stderr)

Now if I run bazel build //kotlin/compiler:symbol-processing-api, the error I got after adding the lines above:

Error in fail: Failed to move jar: java.io.IOException: ERROR: src/main/native/windows/process.cc(202): CreateProcessW("mv" com/google/devtools/ksp/symbol-processing/1.9.23-1.0.20/symbol-processing-1.9.23-1.0.20.jar symbol-processing.jar): The system cannot find the file specified.

The issue not reproducible on MacOS or on Linux.

Poligun avatar Jul 10 '24 03:07 Poligun

@restingbull I still receive the following error with rules_kotlin version 1.9.6: ERROR: D:/bazel_tmp/33apilyc/external/rules_kotlin/kotlin/compiler/BUILD.bazel:23:17: no such target '@com_github_google_ksp//:symbol-processing-cmdline.jar': target 'symbol-processing-cmdline.jar' not declared in package '' defined by D:/bazel_tmp/33apilyc/external/com_github_google_ksp/BUILD.bazel (Tip: use query "@com_github_google_ksp//:*" to see all the targets in that package) and referenced by '@rules_kotlin//kotlin/compiler:symbol-processing-cmdline'

Is there something that needs to be done to get this issue resolved? I am using windows 10 22H2

VFelixBecker avatar Sep 20 '24 06:09 VFelixBecker

Interesting. It must not be related to the symlink, as that code path is unused.

restingbull avatar Sep 20 '24 20:09 restingbull

Tested this also on windows 11. First it did work, but after updating to version 23H2 it throws the same error again.

VFelixBecker avatar Sep 25 '24 16:09 VFelixBecker

Hi @restingbull, is there any update on this topic?

VFelixBecker avatar Oct 21 '24 11:10 VFelixBecker

Given that it worked before the 23H2 update, and I have yet to repro it myself, I'm afraid it exists as an exercise for the user. I'd suggest ensuring the bazel cache is clean and shutdown.

The revised implementation does not rely on any bash functions... meaning any error may be a bazel bug. I'll give it another round, but I do not have a clear understanding why windows fails.

restingbull avatar Oct 21 '24 15:10 restingbull

I did now also receive this error when running ubuntu 22.04 within WSL2. So this seems not to be caused by windows. I have not changed anything within my project, so bazel and rules_kotlin version stayed the same.

Is it possible to get rid of the KSP? I dont even need it.

VFelixBecker avatar Nov 13 '24 09:11 VFelixBecker

Using rules_kotlin version 2.1.4 with Bazel 7.6.1 on macOS 15.5, I just encountered a very similar error for symbol-processing-cmdline, but it reports that the target is not visible as opposed to not declared. Here's the error message:

ERROR: .../external/rules_kotlin~/kotlin/compiler/BUILD.bazel:25:17: in kt_jvm_import rule @@rules_kotlin~//kotlin/compiler:symbol-processing-cmdline: target '@@rules_kotlin~~rules_kotlin_extensions~com_github_google_ksp//:symbol-processing-cmdline.jar' is not visible from target '@@rules_kotlin~//kotlin/compiler:symbol-processing-cmdline'. Check the visibility declaration of the former target if you think the dependency is legitimate. To set the visibility of that source file target, use the exports_files() function
ERROR: .../external/rules_kotlin~/kotlin/compiler/BUILD.bazel:25:17: Analysis of target '@@rules_kotlin~//kotlin/compiler:symbol-processing-cmdline' failed

I am loading rules_kotlin with a bazel_dep declaration in MODULE.bazel. I tried doing a bazel clean --expunge before building the kt_jvm_library target, but the error still occurs. However, I have a .bazelrc file that sets the build --incompatible_no_implicit_file_export option. If I comment out this option, then rules_kotlin will initialize successfully, so it looks like the visibility of the JAR files downloaded from "https://github.com/google/ksp" is not being set correctly.

kpitt avatar May 27 '25 15:05 kpitt