bazelbuild/vscode-bazel

Help installing buildifier into WSL

frankie-frank-frank opened this issue · 1 comments

Whenever I open buildifier in VSCode, I get a pop-up requiring me to download the buildifier setup for linting. However, when I download the amd-64 executable file and run it, I get a blank screen. Can anyone give me a simple descriptive guide on how to go about getting buildifier installed on windows and making it accessible in my wsl project?

Here is how I do it: you need to download a version of buildifier inside the WSL. You can do it in your home directory for example:

cd ~
wget https://github.com/bazelbuild/buildtools/releases/download/v6.4.0/buildifier-linux-amd64

I have a bin directory inside my user directory where my bazelisk installation also resides. I copy `buildifier there too like so:

mv buildifier-linux-amd64 ./bin/buildifier

And then you should make sure that the path to this folder is on your path, for example by adding this line to the .bashrc file in an Ubuntu distribution. If you're connected to your WSL using VS Code, you can directly open it in there

code ~/.bashrc

and add the following line at the end of it:

export PATH=~/bin:$PATH

Finally, you need to add the execute permission to the buildifier executable using chmod:

chmod +x ~/bin/buildifier

Finally, restart VS code and you should be good to go.