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

Warnings from finding build targets #216

Closed
efagerho opened this issue Sep 8, 2020 · 11 comments
Closed

Warnings from finding build targets #216

efagerho opened this issue Sep 8, 2020 · 11 comments
Assignees

Comments

@efagerho
Copy link

efagerho commented Sep 8, 2020

I just tried out Bazel for the first time for a Java project and I ran into an issue that I've never seen with C++ and Python projects. Basically, when I try to hit the "refresh" button on the "Bazel build targets" side panel, I get an error popup like the following:

Command failed: bazel --output_base=/var/folders/cj/1fv063dx1772zbpnfpzvj_c00000gn/T/d855bbcad42db418fe212896af750013 query ...:* --output=package Loading: 0 packages loaded ERROR: error loading package 'bazel-bazeljava/external/rules_jvm_external': Every .bzl file must have a corresponding package, but '//:private/versions.bzl' does not have one. Please create a BUILD file in the same or any parent directory. Note that this BUILD file does not need to do anything except exist. Loading: 12 packages loaded currently loading: bazel-bazeljava/external/local_config_cc ... (9 packages) Loading: 12 packages loaded currently loading: bazel-bazeljava/external/local_config_cc ... (9 packages)

The error is slightly different each time and seems to be located in different external packages. Maybe my version of Bazel has some issues with the external dependencies that are being loaded.

Bazel version: 3.5.0
VSCode version: 1.48.2

Steps to reproduce:

  1. Clone the repository: https://github.com/efagerho/bazeljava
  2. Run: bazel build ...
  3. Open repository in VSCode
  4. Click the refresh button under "Bazel build targets"

I don't see anything wrong with my project WORKSPACE file. If I manually run bazel query ...:* in the root, I don't see any errors and all build targets are properly listed. Seems like correct behavior would be for VSCode to list all the local targets in my workspace and not fail because of issues with external dependencies.

@ian-h-chamberlain
Copy link

I was able to fix this by deleting the folder listed as the --output_base= argument, which forced the extension to re-fetch the apparently missing dependencies.
Presumably running the "Bazel: Clean" command would have the same effect. Hopefully this helps anyone else running into this issue!

My extension + Bazel info:

$ bazel version 
Bazelisk version: 1.6.1
Build label: 3.3.0
Build target: bazel-out/darwin-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Wed Jun 17 12:59:56 2020 (1592398796)
Build timestamp: 1592398796
Build timestamp as int: 1592398796

Extension

Name: Bazel
Id: bazelbuild.vscode-bazel
Description: Bazel BUILD integration
Version: 0.4.0
Publisher: The Bazel Team
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=BazelBuild.vscode-bazel

@efagerho
Copy link
Author

Yes, the reason for step (2) in my repro is that you need to have the pulled down and compiled the external deps before you see a failure. A bazel clean also solves the problem, but VSCode immediately starts failing again once you build a target and it has pulled down the external deps.

@nullas
Copy link

nullas commented Sep 17, 2020

I encountered a similar issue.
The error message indicates the rules_jvm_external missed a BUILD file under //private/ directory or its any parent directory. The latest code has the BUILD. You probably need to upgrade rules_jvm_external.

@efagerho
Copy link
Author

I'm using the latest release of rules_jvm_external.

@nfisher
Copy link

nfisher commented Oct 7, 2020

Try this, it worked for me:
bazelbuild/bazel#10653 (comment)

You'll need to ensure you name your workspace. To do that put workspace(name="UNIQUE_NAME_HERE") at the top of your projects WORKSPACE file.

@OscarVanL
Copy link

For me, this problem was rectified by opening the VSCode Bazel extension settings, finding the "Queries Share Server" checkbox, and ensuring it is ticked (unticked by default).

The box has the description: "Use the same Bazel server for queries and builds. By default, vscode-bazel uses a separate server for queries so that they can be executed in parallel with builds. You can enable this setting if running multiple Bazel servers has a negative performance impact on your system, but you may experience degraded performance in Visual Studio Code for operations that require queries."

@vorburger
Copy link

see also #261

@cameron-martin
Copy link
Collaborator

As mentioned in #328 (comment), this seems like an issue with bazel. I'll open an issue there and see what they say.

@cameron-martin cameron-martin self-assigned this Jan 23, 2024
@cameron-martin
Copy link
Collaborator

cameron-martin commented Jan 23, 2024

Looks like we already have an issue open here actually: bazelbuild/bazel#10653. Considering that issue has been open for 4 years, maybe we could implement a workaround in vscode-bazel.

For example, we could pass --deleted_packages when invoking bazel to ignore these symlinks.

cameron-martin added a commit that referenced this issue Jan 26, 2024
The bazel query used to introspect the targets available incorrectly traverses convenience symlinks when the output base has changed. This is a bug in Bazel (see bazelbuild/bazel#10653). A lot of people are hitting this, since it happens with the default setup of bazel and this plugin. Until it is fixed upstream, this works around this issue by enabling the `queriesShareServer` option by default.

Workaround for #216

Co-authored-by: Cameron Martin <cameronmartin123@gmail.com>
@cameron-martin
Copy link
Collaborator

This'll be fixed in Bazel 7.1.0. See bazelbuild/bazel#21505

@cameron-martin
Copy link
Collaborator

Bazel 7.1.0 is now released and I opened #355 to revert the workaround, so I'll close this.

cameron-martin added a commit that referenced this issue Mar 12, 2024
This reverts commit 64c9d7e.

The underlying issue that this addresses is now fixed in Bazel 7.1.0. See #216 and bazelbuild/bazel#21505.
cameron-martin added a commit to cameron-martin/vscode-bazel that referenced this issue Mar 13, 2024
)"

This reverts commit 64c9d7e.

The underlying issue that this addresses is now fixed in Bazel 7.1.0. See bazel-contrib#216 and bazelbuild/bazel#21505.
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

7 participants