bazelbuild / vscode-bazel

Bazel support for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=BazelBuild.vscode-bazel
Apache License 2.0
232 stars 76 forks source link

Open Trivial Bazel 6.4.0 Java example project causes `Command failed: bazel ...` error on opening it in VSC #328

Closed vorburger closed 5 months ago

vorburger commented 6 months ago

When I open code java_one/ of https://github.com/vorburger/LearningBazel a notification pop ups with the following error:

Command failed: bazel --output_base=/tmp/07d06c474e5b9ccb01482f273e2b80b3 query ...:* --output=package
Loading: 0 packages loaded
ERROR: error loading package under directory '': error loading package 'bazel-java-one/external/bazel_tools/tools/android': Label '//tools/python:private/defs.bzl' is invalid because 'tools/python' is not a package; perhaps you meant to put the colon here: '//:tools/python/private/defs.bzl'?
Loading: 1 packages loaded
    currently loading: bazel-java-one/external/remote_java_tools ... (4 packages)
vorburger commented 6 months ago

The error message actually seems to vary slightly, e.g. when I open code rules_jvm_external/ of https://github.com/vorburger/LearningBazel then it is the following (but I suspect this is likely all due to some same root cause issue):

Command failed: bazel --output_base=/tmp/33f1df7beca4082e021dfd08c653c0c8 query ...:* --output=package
Loading: 0 packages loaded
ERROR: error loading package under directory '': error loading package 'bazel-rules_jvm_external/external/rules_jvm_external~5.3/tests/unit/manifest_stamp': Unable to find package for @[unknown repo 'bazel_skylib' requested from @]//rules:diff_test.bzl: The repository '@[unknown repo 'bazel_skylib' requested from @]' could not be resolved: No repository visible as '@bazel_skylib' from main repository.
Loading: 6 packages loaded
    currently loading: bazel-rules_jvm_external/external/rules_jvm_external~5.3~maven~maven ... (6 packages)
cameron-martin commented 5 months ago

This seems to be a quirk of setting a different --output_base to what you last built with. The bazel-* symlinks then don't point to the current output base, so bazel no longer ignores them. Seems like a bug in Bazel. I reckon open an issue there.

cameron-martin commented 5 months ago

Duplicate of #216