Giter Club home page Giter Club logo

Comments (16)

stevebarrau avatar stevebarrau commented on June 24, 2024 2

Thanks for the repro repo. I get the same error as you.

This looks like an issue with our use of FindBinary here:

javaParserPath, found := bazel.FindBinary("java/src/com/github/bazel_contrib/contrib_rules_jvm/javaparser/generators", "Main")

Hardcoding javaParserPath to "external/contrib_rules_jvm/java/src/com/github/bazel_contrib/contrib_rules_jvm/javaparser/generators/Main" works is your case (and you could patch this in until we find a solution) but this will not work long term I imagine.

I will try to have a look at what is going on this week.

from rules_jvm.

stevebarrau avatar stevebarrau commented on June 24, 2024

Can you share your version of Bazel and ideally a repo with a repro?

from rules_jvm.

KrisJohnstone avatar KrisJohnstone commented on June 24, 2024

Can you share your version of Bazel and ideally a repo with a repro?

I've tried 6.3.0, 6.1.0 and 5.4.1.

I've been able to replicate here:
https://github.com/KrisJohnstone/spring-petclinic/tree/bazel-example

from rules_jvm.

KrisJohnstone avatar KrisJohnstone commented on June 24, 2024

That worked a treat. Thanks @stevebarrau

EDIT: Did you want me to close this Issue or leave it open for the fix?

from rules_jvm.

stevebarrau avatar stevebarrau commented on June 24, 2024

@KrisJohnstone can you give #216 a try and see if this resolve this issue?

from rules_jvm.

KrisJohnstone avatar KrisJohnstone commented on June 24, 2024

I get the following weirdly:

/private/var/tmp/_bazel_krisjohnstone/3337dddeaeeddd03860ac735ca6cd027/execroot/main/bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/contrib_rules_jvm/java/src/com/github/bazel_contrib/contrib_rules_jvm/javaparser/generators/Main: Cannot locate runfiles directory. (Set $JAVA_RUNFILES to inhibit searching.)
10:28PM FTL external/contrib_rules_jvm/java/gazelle/configure.go:133 > could not start javaparser error="failed to start / connect to javaparser server: failed to read port from javaparser server - maybe it crashed: timed out waiting for port file to be written by javaparser server"

from rules_jvm.

gkze avatar gkze commented on June 24, 2024

Same here - after trying #216

from rules_jvm.

ar3s3ru avatar ar3s3ru commented on June 24, 2024

Same here too with #216. I will add: I'm using Bzlmod.

/private/var/tmp/_bazel_ar3s3ru/3efe07ce4123e4dfef2f8db5ddd896ff/execroot/_main/bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/contrib_rules_jvm~override/java/src/com/github/bazel_contrib/contrib_rules_jvm/javaparser/generators/Main: Cannot locate runfiles directory. (Set $JAVA_RUNFILES to inhibit searching.)
8:46AM FTL external/contrib_rules_jvm~override/java/gazelle/configure.go:133 > could not start javaparser error="failed to start / connect to javaparser server: failed to read port from javaparser server - maybe it crashed: timed out waiting for port file to be written by javaparser server"
Error: bazel exited with exit code: 1

from rules_jvm.

jtcarnes avatar jtcarnes commented on June 24, 2024

I'll say I'm using bzlmod as well and am hitting the same issue. Mine is for using the gazelle plugin, but the error is the same.

For reproducibility:

bazelrc:

common --java_language_version=remotejdk_11 --tools_java_runtime_version=remotejdk_11 --tool_java_language_version=11

MODULE.bazel

module(name = "test")

bazel_dep(name = "gazelle", version = "0.34.0")
bazel_dep(name = "contrib_rules_jvm", version = "0.18.0")

BUILD.bazel:

load("@gazelle//:def.bzl", "DEFAULT_LANGUAGES", "gazelle", "gazelle_binary")
gazelle(
    name = "gazelle",
    gazelle = ":gazelle_bin",
)

gazelle_binary(
    name = "gazelle_bin",
    languages = DEFAULT_LANGUAGES + [
        "@contrib_rules_jvm//java/gazelle",
    ],
)

Running Gazelle:

bazel run //:gazelle                                                                                                                                                                                                                                              ✔ 
INFO: Analyzed target //:gazelle (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //:gazelle up-to-date:
  bazel-bin/gazelle-runner.bash
  bazel-bin/gazelle
INFO: Elapsed time: 0.039s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Running command line: bazel-bin/gazelle
2:09PM FTL external/contrib_rules_jvm~0.18.0/java/gazelle/configure.go:133 > could not start javaparser error="failed to start / connect to javaparser server: failed to find javaparser in runfiles"

from rules_jvm.

ar3s3ru avatar ar3s3ru commented on June 24, 2024

I've opened #224 to fix the issue with locating javaparser.

However, in my specific case, I'm hitting a different error now: Cannot locate runfiles directory.

Can some of you try on your side my branch version and report if you're hitting the same issue?

You can use the following override if you're on Bzlmod

git_override(
    module_name = "contrib_rules_jvm",
    remote = "https://github.com/ar3s3ru/rules_jvm",
    commit = "b01bab003632dc0624a4e8ff1d4354881ee95a7c",
)

Some details on my local project:

  • Bazel: 6.4.0
  • Bzlmod on

Error output:

Loading: 
Loading: 
Loading: 0 packages loaded
Analyzing: target //:gazelle (0 packages loaded, 0 targets configured)
INFO: Analyzed target //:gazelle (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
[0 / 7] [Prepa] BazelWorkspaceStatusAction stable-status.txt
Target //:gazelle up-to-date:
  bazel-bin/gazelle-runner.bash
  bazel-bin/gazelle
INFO: Elapsed time: 1.315s, Critical Path: 1.16s
INFO: 3 processes: 1 internal, 2 darwin-sandbox.
INFO: Build completed successfully, 3 total actions
INFO: Running command line: bazel-bin/gazelle
�[90m2:07PM�[0m �[32mINF�[0m �[1mexternal/contrib_rules_jvm~override/java/gazelle/private/servermanager/servermanager.go:70�[0m�[36m >�[0m starting javaparser with command �[36mcmd=�[0m"/private/var/tmp/_bazel_ar3s3ru/3efe07ce4123e4dfef2f8db5ddd896ff/execroot/_main/bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/contrib_rules_jvm~override/java/src/com/github/bazel_contrib/contrib_rules_jvm/javaparser/generators/Main --jvm_flag=-Dorg.slf4j.simpleLogger.defaultLogLevel=info --server-port-file-path /var/folders/dg/jf2qkwmn0qg4qklxq9c84j0w0000gn/T/gazelle-javaparser1138877067/port --workspace /Users/ar3s3ru/Code/*** --idle-timeout 30"
/private/var/tmp/_bazel_ar3s3ru/3efe07ce4123e4dfef2f8db5ddd896ff/execroot/_main/bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/contrib_rules_jvm~override/java/src/com/github/bazel_contrib/contrib_rules_jvm/javaparser/generators/Main: Cannot locate runfiles directory. (Set $JAVA_RUNFILES to inhibit searching.)
�[90m2:07PM�[0m �[1m�[31mFTL�[0m�[0m �[1mexternal/contrib_rules_jvm~override/java/gazelle/configure.go:133�[0m�[36m >�[0m could not start javaparser �[36merror=�[0m�[31m"failed to start / connect to javaparser server: failed to read port from javaparser server - maybe it crashed: timed out waiting for port file to be written by javaparser server"�[0m
Error: bazel exited with exit code: 1

from rules_jvm.

ar3s3ru avatar ar3s3ru commented on June 24, 2024

Seems like the error I was mentioning above was happening since JAVA_RUNFILES was not being passed to the javaparser/generators/Main's java_binary invoked by Gazelle's plugin, due to this: https://github.com/bazelbuild/bazel/blob/492ee4c91b507bc07f63da1bafa1696cbcf75bd2/src/main/java/com/google/devtools/build/lib/bazel/rules/java/java_stub_template.txt#L185

(More context here: https://bazelbuild.slack.com/archives/C01HMGN77Q8/p1701887957242259)

My latest commit apparently fixes that, at least on my private repro project: b01bab0

from rules_jvm.

misberner avatar misberner commented on June 24, 2024

Great to see this is fixed! 🎉 Is there already a plan for when a new release including this will get cut?

from rules_jvm.

illicitonion avatar illicitonion commented on June 24, 2024

I just released v0.20.0 including this fix.

from rules_jvm.

misberner avatar misberner commented on June 24, 2024

Amazing, thanks for the quick turnaround on this!

from rules_jvm.

ar3s3ru avatar ar3s3ru commented on June 24, 2024

@illicitonion I don't see that version in BCR 👀

from rules_jvm.

illicitonion avatar illicitonion commented on June 24, 2024

It looks like we don't have automatic BCR mirroring enabled - you can following along at bazelbuild/bazel-central-registry#1268 to see how our progress at getting automatic mirroring working goes.

from rules_jvm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.