Go Command Not Found After Installation on WSL Ubuntu 20.04 – How to Fix

bashenvironment-variablesgolang

I've been struggling with this (seemingly) straightforward installation. If I run echo $PATH I get the following as part of the output /usr/local/go/bin:/usr/local/go-1.19.2/bin. What's even more interesting is that I am able to run sudo /usr/local/go/bin/go version and it works. But go version doesn't.

Here's a detailed description of everything I've done so far:

I installed go by following the exact instructions on the website. I then tried to mv into /usr/local/ but I encountered a weird error that I couldn't figure out. I then simply used cp to move the directory. Then I added the export Path command in my .profile as directed. Command 'go' not found.

I've tried adding PATH to .bashrc, I've tried exporting GOPATH, GOROOT, and various other things suggested in other threads. Nothing seems to work. I then scrubbed everything clean and started again, removing any extra go PATH variables. Still nothing.

Please Help.

Best Answer

Finally figured it out. For SOME reason, the go folder in /usr/local was not executable. Changed the file permissions, and it's working now. Leaving this question here in case someone else finds this useful.

Related Question