vscode-bazel
vscode-bazel copied to clipboard
make buildifier warning less aggressive
This extension's warning about no buildifier being found is overly eager, and presumes that the environment should have a single, global buildifier executable shared by multiple projects.
But developers often prefer to have project-local versions of their tool dependencies (and no global version) for better reproducibility, which is even facilitated for buildifier by https://github.com/keith/buildifier-prebuilt. Note that all projects created via aspect init use this setup (see https://github.com/aspect-build/aspect-workflows-template).
Such users can add something like the following to ensure that a buildifier binary is available when their projects are opened and that the Bazel extension is configured to use it:
.vscode/tasks.json:
{
// Build `buildifier` on folderOpen to ensure that a buildifier binary exists which the
// VSCode Bazel plugin can use.
"label": "Build buildifier",
"command": "bazel build @buildifier_prebuilt//:buildifier",
"presentation": {
"reveal": "never",
"panel": "new"
},
"runOptions": {
"runOn": "folderOpen",
},
"type": "shell",
}
.vscode/settings.json:
{
"bazel.buildifierExecutable": "bazel-bin/external/buildifier_prebuilt~/buildifier/buildifier",
}
But even with this configuration, this extension still nags about no buildifier being found, because the check for it completes a split second before it's finished building, and it's never checked for again.
If the initial check fails, how about doing a retry or two with a sensible backoff?
cc @alexeagle