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

Make Bazel integration more fault tolerant with --keep_going #287

Open
Silic0nS0ldier opened this issue Jun 15, 2024 · 0 comments · May be fixed by #288
Open

Make Bazel integration more fault tolerant with --keep_going #287

Silic0nS0ldier opened this issue Jun 15, 2024 · 0 comments · May be fixed by #288

Comments

@Silic0nS0ldier
Copy link

Silic0nS0ldier commented Jun 15, 2024

Currently the Bazel integration is fragile, requiring a full successful aquery pass. This means LSP results are significantly diminished in some common scenarios such as;

  • No network access with an incomplete cache (repo fetch failures).
  • Build configuration errors ("no such target", "no such package", "no matching toolchains").
  • Invalid target state (select(...) no match errors).
  • Missing pre-requisities (fail(...) in repo rules).

Adding --keep_going (and attempting to process output irrespective of the exit code) should greatly improve LSP capabilities when the latter errors (and any others not mentioned) occur.

"bazel",
"aquery",
"--output=proto",
"--include_aspects", // required for java_proto_library, see
// https://stackoverflow.com/questions/63430530/bazel-aquery-returns-no-action-information-for-java-proto-library
"--allow_analysis_failures",
"mnemonic(" + filterMnemonic + ", " + kindUnion + ")"

Request Context

I am currently using the VSCode extension distribution of this language server to aid Bazel development. The core Java completion is working well (much better than https://github.com/salesforce/bazel-vscode-java) however many imports fail to resolve.

For reference, here are some samples of the errors running aquery against the Bazel repo.

Python repo failing to fetch as current user is root (default in a dev container).

ERROR: An error occurred during the fetch of repository 'rules_python~~python~python_3_8_x86_64-unknown-linux-gnu':
   Traceback (most recent call last):
        File "/root/.cache/bazel/_bazel_root/af358cfbcc0478b6bbe6e5ca9711bb0d/external/rules_python~/python/repositories.bzl", line 199, column 25, in _python_repository_impl
                fail("The current user is root, please run as non-root when using the hermetic Python interpreter. See https://github.com/bazelbuild/rules_python/pull/713.")
Error in fail: The current user is root, please run as non-root when using the hermetic Python interpreter. See https://github.com/bazelbuild/rules_python/pull/713.

Missing targets, usually this points to a build configuration error however in the case of the Bazel source I believe this is due to unique build requirements.

ERROR: /workspaces/bazel/tools/BUILD:75:10: no such target '//tools/android:bzl_srcs': target 'bzl_srcs' not declared in package 'tools/android' defined by /workspaces/bazel/tools/android/BUILD and referenced by '//tools:bzl_srcs'

Missing packages, similar reasoning to the latter.

ERROR: /workspaces/bazel/src/tools/one_version/BUILD:52:11: no such package 'third_party/bazel/src/tools/one_version': BUILD file not found in any of the following directories. Add a BUILD file to a directory to mark it as a package.
 - /workspaces/bazel/third_party/bazel/src/tools/one_version and referenced by '//src/tools/one_version:one_version'

Android SDK is not installed on the host.

ERROR: /workspaces/bazel/src/test/shell/bazel/android/BUILD:191:16: configurable attribute "data" in //src/test/shell/bazel/android:resource_processing_integration_test_with_head_android_tools doesn't match this configuration: This test requires an android SDK, and one isn't present. Make sure to uncomment the android rules in the WORKSPACE.bzlmod.

This instance of //src/test/shell/bazel/android:resource_processing_integration_test_with_head_android_tools has configuration identifier 2ffb6a1. To inspect its configuration, run: bazel config 2ffb6a1.

For more help, see https://bazel.build/docs/configurable-attributes#faq-select-choose-condition.
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

Successfully merging a pull request may close this issue.

1 participant