bazel-diff icon indicating copy to clipboard operation
bazel-diff copied to clipboard

bazel diff failing when running via bazelisk

Open andre-dialpad opened this issue 2 months ago • 4 comments

When running bazel-diff with bazelisk I'm getting the following error:

Output

(bash)$ bazelisk run @bazel-diff//cli:bazel-diff -- generate-hashes -tt SourceFile -w ${PWD}
Starting local Bazel server (8.1.1) and connecting to it...
INFO: Invocation ID: 1e1893e2-8708-4808-8768-e4f9297d5ee3
ERROR: Analysis of target '@@bazel-diff+//cli:bazel-diff' failed; build aborted: in tag at https://bcr.bazel.build/modules/grpc-java/1.62.2/MODULE.bazel:89:15: no repository visible as '@com_google_protobuf_javalite' to the module '[email protected]', but referenced by label '@com_google_protobuf_javalite//:protobuf_javalite' in attribute 'target' of tag 'override'.
INFO: Elapsed time: 8.421s, Critical Path: 0.02s
INFO: 1 process: 1 internal.
ERROR: Build did NOT complete successfully
ERROR: Build failed. Not running target
FAILED: 
    Fetching repository @@rules_cc++cc_configure_extension+local_config_cc; starting
    Fetching repository @@rules_java++toolchains+remote_java_tools; starting
    Fetching repository @@rules_kotlin++rules_kotlin_extensions+com_github_jetbrains_kotlin_git; starting
    Fetching /home/andrefsp/.cache/bazel/go-core/base/external/rules_java++toolchains+remote_java_tools; Extracting java_tools-v13.18.zip
    Fetching /home/andrefsp/.cache/bazel/go-core/base/external/rules_kotlin++rules_kotlin_extensions+com_github_jetbrains_kotlin_git; Extracting kotlin-compiler-2.1.0.zip
    Fetching repository @@rules_java++toolchains+remotejdk11_linux; starting
    Fetching repository @@rules_python++python+python_3_11_x86_64-unknown-linux-gnu; starting
    Fetching repository @@rules_kotlin++rules_kotlin_extensions+com_github_google_ksp; starting ... (10 fetches)

This error seems to only happen when installing bazel-diff via MODULE.bazel:

# MODULE.bazel
bazel_dep(name = "bazel-diff", version = "9.0.3")

VERSIONS:

(bash)$ java --version 
openjdk 21.0.8 2025-07-15
OpenJDK Runtime Environment (build 21.0.8+9-Ubuntu-0ubuntu124.04.1)
OpenJDK 64-Bit Server VM (build 21.0.8+9-Ubuntu-0ubuntu124.04.1, mixed mode, sharing)

(bash)$ javac --version 
javac 21.0.8

andre-dialpad avatar Sep 30 '25 13:09 andre-dialpad

Managed to fix this error by adding on MODULE.bazel

bazel_dep(name = "grpc-java", version = "1.75.0")

andre-dialpad avatar Oct 01 '25 12:10 andre-dialpad

@andre-dialpad Did you add that to Bazel-diff or to you repo?

tinder-maxwellelliott avatar Oct 09 '25 13:10 tinder-maxwellelliott

@tinder-maxwellelliott yes.

# MODULE.bazel

bazel_dep(name = "grpc-java", version = "1.75.0")

# bazel diff
bazel_dep(name = "bazel-diff", version = "10.1.0")

It's worth to point out that even though it's working we are still getting some warnings and errors.

17:03:47  ERROR: Skipping '//external:all-targets': no such package 'external': //external package is not available since the WORKSPACE file is disabled, please migrate to Bzlmod or temporarily enable WORKSPACE via --enable_workspace. See https://bazel.build/external/migration#bind-targets.
17:03:48  
17:03:48  WARNING: --keep_going specified, ignoring errors. Results may be inaccurate

These messages only started to appear when we introduced bazel-diff via MODULE.bazel.

andre-dialpad avatar Oct 15 '25 13:10 andre-dialpad

Yes as in you added it to your repo? Not to Bazel-diff? That's really strange since we are passing in BCR. I can add it if it's truly needed.

As for those logs can you try adding --excludeExternalTargets to generate-hashes?

tinder-maxwellelliott avatar Oct 20 '25 19:10 tinder-maxwellelliott

@tinder-maxwellelliott The first "yes" was that I added those lines to my repo.

I've followed your previous advice and adding --excludeExternalTargets seems to have clear the errors and I didnt find any issue so far.

In think maybe logging the //external:all-targets as a warning instead of a error is probably better but I'm not sure.

andre-dialpad avatar Dec 22 '25 14:12 andre-dialpad