You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(config): support manual Bazel workspace root selection (#687)
* feat(config): add bazel.workspacePath to manually specify workspace
Add a new configuration option `bazel.workspacePath` that allows users
to manually specify the Bazel workspace directory path. This is useful
when:
- Working with multiple MODULE.bazel files in nested directories
- The auto-detection picks the wrong workspace root
- Using local_path_override with multiple repositories
The path can be absolute or relative to the VS Code workspace folder.
Fixes#621
* test: add unit tests for getBazelWorkspaceFolder with workspacePath config
Add tests to verify:
- Auto-detection works when workspacePath is not configured
- Configured absolute path is used correctly
- Configured relative path is resolved correctly
- Invalid configured path falls back to auto-detection
- Configured path takes precedence over nested MODULE.bazel
* fix: handle Bazel roots nested under workspace folders
Prevent parent or unrelated VS Code folders from producing invalid //../... package queries, and resolve tree selections relative to the configured Bazel root.
* chore: fix workspace path lint after rebase
* fix: complete manual workspace path support
* fix: resolve Bazel executable from workspace roots
* test: pin Bazel version for nested module
* test: allow more time for Bazel queries on CI
Workspace-tree integration tests issue several sequential Bazel queries.
On slower CI runners, server startup can exceed 10 seconds and cause
intermittent timeouts, so raise the suite timeout to 30 seconds.
---------
Co-authored-by: Zsi-r <zsr949480148@gmail.com>
Copy file name to clipboardExpand all lines: README.md
+13Lines changed: 13 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,6 +38,19 @@ this extension does not automatically _fix_ lint warnings during formatting,
38
38
but you can opt into this by enabling the **Bazel: Buildifier Fix on Format**
39
39
setting.
40
40
41
+
### Selecting the Bazel workspace root
42
+
43
+
The extension automatically searches upward for a `MODULE.bazel`,
44
+
`REPO.bazel`, `WORKSPACE.bazel`, or `WORKSPACE` file. If that selects the wrong
45
+
root, or if the Bazel root is nested below the folder opened in VS Code, set
46
+
`bazel.workspacePath` to the Bazel root. The value can be an absolute path or a
47
+
path relative to the VS Code workspace folder.
48
+
49
+
The extension supports one Bazel root per VS Code workspace folder. To work
50
+
with multiple independent Bazel roots, use a VS Code multi-root workspace and
51
+
add each Bazel root as a separate folder; `bazel.workspacePath` can then be set
52
+
independently for each folder.
53
+
41
54
### Using a separate output base
42
55
43
56
By default this extension will use the default output base for running queries. This will cause builds to block queries, potentially causing degraded performance. In Bazel versions since 7.1 it is safe to disable this by changing the `bazel.queriesShareServer` setting to `false`. In earlier versions it can be safely disabled after adding the convenience symlinks to `.bazelignore`, for example:
Copy file name to clipboardExpand all lines: package.json
+7-2Lines changed: 7 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -175,6 +175,12 @@
175
175
"default": true,
176
176
"markdownDescription": "Whether to enable Buildifier support for formatting and linting Bazel files. When enabled, provides document formatting and lint diagnostics for BUILD, WORKSPACE, and .bzl files."
177
177
},
178
+
"bazel.workspacePath": {
179
+
"type": "string",
180
+
"default": "",
181
+
"markdownDescription": "Pins the single Bazel workspace root used for this VS Code workspace folder. The path can be absolute or relative to the VS Code workspace folder. If unset, the extension searches for `MODULE.bazel`, `REPO.bazel`, `WORKSPACE.bazel`, or `WORKSPACE`. To use multiple independent Bazel roots, add each root as a folder in a VS Code multi-root workspace and configure this setting per folder.",
0 commit comments