vscode-bazel
vscode-bazel copied to clipboard
Command fails from extension but succeeds in my terminal
I seem to be getting errors when using almost any Bazel command from the palette, as shown below.
rejected promise not handled within 1 second: Error: Command failed: bazel --output_base=<redacted path> query kind('.* rule', ...) --output=proto
Starting local Bazel server and connecting to it...
Loading: 0 packages loaded
ERROR: error loading package 'bazel-plh/external/bazel_tools/tools/cpp': at D:/paul/plh/bazel-plh/external/bazel_tools/tools/cpp/compiler_flag.bzl:17:6: Label '//tools/cpp:toolchain_utils.bzl' is invalid because 'tools/cpp' is not a package; perhaps you meant to put the colon here: '//:tools/cpp/toolchain_utils.bzl'?
Loading: 68 packages loaded
currently loading: bazel-plh/external/bazel_tools/tools/android ... (38 packages)
Loading: 68 packages loaded
currently loading: bazel-plh/external/bazel_tools/tools/android ... (38 packages)
E @ console.ts:137
I've tried running the same command in the terminal and it succeeds if and only if I'm adding quotations around the query.
I think what's happening is you need to run a build or something to actually create all necessary analysis files.
Eg
bazel --output_base=/tmp/4d8027e6d32eeb7619bc14d5897e6dd1 query '//...:*' --output=package
will fail, but if you run
bazel --output_base=/tmp/4d8027e6d32eeb7619bc14d5897e6dd1 build //:some_target
and then run
bazel --output_base=/tmp/4d8027e6d32eeb7619bc14d5897e6dd1 query '//...:*' --output=package
again it will work. If you turn on "Queries Share Server" and force VS Code to build some target, I would expect this to work. It at least fixes "Bazel Build Targets" in the sidebar which has never worked for me.
Same issue here. Tried with "Queries Share Server" and without, same issue. in my case it blows up with error:
[31m[1mERROR: [0merror loading package '<redacted>/external/io_bazel_rules_scala/<redacted>': Label '//scala:providers.bzl' is invalid because 'scala' is not a package; perhaps you meant to put the colon here: '//:scala/providers.bzl'?
Where scala dep is:
# Scala Rules
git_repository(
name = "io_bazel_rules_scala",
commit = "ddde9b3c21fd872aa8b1b035247dec333d04cb14",
remote = "https://github.com/bazelbuild/rules_scala",
shallow_since = "1651212619 +0300",
)
But this command works if I run it manually in my terminal:
» bazel query "kind('.* rule', ...)" --output=package >/dev/null 2>&1 && echo "ok"
ok
Duplicate of #216