Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command fails from extension but succeeds in my terminal #265

Closed
paulherman opened this issue May 13, 2022 · 3 comments
Closed

Command fails from extension but succeeds in my terminal #265

paulherman opened this issue May 13, 2022 · 3 comments

Comments

@paulherman
Copy link

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.

@aschleck
Copy link

aschleck commented Jul 1, 2022

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.

limdor added a commit to limdor/vscode-bazel that referenced this issue Jul 25, 2022
The bazel query used to introspect the targets available assumes that the generated files are
already there.
This creates the problem that you have to first generate the files once.
bazel-contrib#265

Not sharing the same server makes it harder because the output is a random one.
This means that for a normal user, it will be hard to make it work when query does not
use the same server like your normal bazel queries.
Because of that, it is better to have the queriesShareServer to true by default
and the expert users can set it to false if they want.
@cono
Copy link

cono commented Nov 11, 2022

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

@cameron-martin
Copy link
Collaborator

Duplicate of #216

@cameron-martin cameron-martin marked this as a duplicate of #216 Jan 23, 2024
@cameron-martin cameron-martin closed this as not planned Won't fix, can't repro, duplicate, stale Jan 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants