bazel-contrib / bazel-contrib/vscode-bazel

Regarding the issue of syncing external dependencies in VScode

Open
#579 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
296
Forks
108
Avg merge
3d 22h
Merged PRs (30d)
5

Description

When developing Java projects managed by Bazel in VSCode, external Maven dependencies declared via maven.install(rules_jvm_external) or Bzlmod are consistently flagged as "not found" or "unknown packages" in the editor (displayed with red error underlines). Code completion, navigation, and other intelligent features fail for these dependencies. However, the project can be built and run successfully via bazel build, and the dependencies are correctly downloaded to the Bazel cache. The same project works perfectly in IntelliJ IDEA (using the official Bazel plugin), with all dependencies recognized correctly.

Core Symptoms:

In VSCode:​ importstatements show errors, e.g., "Cannot resolve symbol 'XXX'".

Actual Build:​ The bazel build //...command succeeds, proving dependencies are present and correctly linked.

Comparative Test:​ No such issue occurs in IntelliJ IDEA; dependency recognition works normally.

Root Cause Analysis:

This is not a configuration error but a toolchain gap in the VSCode extension ecosystem.

Separation of Responsibilities:​ The core engine providing Java intelligence is the "Language Support for Java(TM) by Red Hat"​ extension. It relies on a project model to obtain the classpath.

Support Limitation:​ This Red Hat Java extension is primarily designed to parse standard Maven (pom.xml)​ and Gradle (build.gradle)​ project models. It lacks built-in capability​ to parse Bazel-specific dependency declaration files (e.g., maven.install rules in MODULE.bazel or WORKSPACE).

Broken Information Flow:​ While the "Bazel" extension handles build tasks, its current version (0.13.2) does not appear to synchronize the precise dependency list and JAR file paths calculated by Bazel with the Red Hat Java language server. Consequently, the language server "cannot see" these downloaded dependencies, leading to errors.

Contrast with Working Cases:​ The Maven for Javaand Gradle for Javaextensions succeed because they are specifically responsible​ for translating and injecting​ their respective build system's project model and dependency paths into the Red Hat Java language server. The Bazel extension currently lacks this crucial "adapter layer".

Environment Information:

OS:​ Windows 11 Pro 23H2

Editor:​ TRAE CN V3.3.37 (VSCode-based)

Build Tool:​ Bazel 9.0.0

Relevant Extensions:

Bazel: 0.13.2

Language Support for Java(TM) by Red Hat: 1.53.0

Maven for Java: 0.45.1

Extension Pack for Java: 0.30.5

Contributor guide

Open the contributing guide

Research direction

Reproduce the missing dependency recognition with Bazel 9.0.0, Bazel extension 0.13.2, and Language Support for Java 1.53.0 in the stated VSCode-based environment. Inspect how the Bazel extension exposes dependencies to the Red Hat Java language server, comparing the working Maven and Gradle integrations. Done means Maven dependencies from maven.install or Bzlmod are recognized for imports, completion, and navigation without breaking bazel build.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, typescript, vscode
Domain
build-system, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.