Not able to install Gopls in VSCode due to Permission issues

529 views Asked by At

After installing Golang and setting up the GOPATH in .bashrc, I am not able to install the Gopls and other tools that VSCode requires to be installed.

When I am clicking the Install button in the VSCode popup, it fails to install stating permission issues. On going through the error logs, I see that VSCode is trying to install the packages to the GOBIN directory which is set to /user/local/bin. This directory by default is read-only, therefore the installation is failing.

I can solve this issue by using the Linux terminal by installing the packages with sudo. But that's not the point. I want to fix the issue within VSCode itself.

I know it's not a Golang issue, but something related to Linux.

1

There are 1 answers

0
Avik On

The issue can be fixed by unsetting the GOBIN env variable by:

go env -w GOBIN=''

You can cross-check all the go env by: go env

On restarting the VSCode and clicking the "Install" button in the pop-up, the packages are installed in the GOPATH, which is an editable directory.