Introduction
This article is for discussing on how to solve an error message. The error message exists as part of the title of this article. It is ‘-su: /snap/bin/go: No such file or directory’. The error message is an output of a command execution. The following is the execution of the command :
root@hostname:~# go -su: /snap/bin/go: No such file or directory root@hostname:~#
The error is available after the removal of the ‘go’ command. The ‘go’ command represents the command for executing golang source code. This is the command for the ‘go’ command removal from snap :
root@hostname:~# snap remove go go removed root@hostname:~#
After the removal process of ‘go’, the error appear. So, there are several solution for solving the problem. The first solution is to install go using apt package manager. Just read the article in this link to install it. But after installing the ‘go’ utility using apt package manager, the error still persist.
Solving the problem
In order to solve the problem, just execute the following steps :
1. First of all, check the go command. Just type the following command :
user@hostname:/usr/bin$ which go /usr/bin/go user@hostname:/usr/bin$
2. So, the command exist in the path as in the output of the above command. Next, try to execute the full path of the ‘go’ command as follows :
user@hostname:/usr/bin$ /usr/bin/go Go is a tool for managing Go source code. Usage: go command [arguments] The commands are: build compile packages and dependencies clean remove object files and cached files doc show documentation for package or symbol env print Go environment information bug start a bug report fix update packages to use new APIs fmt gofmt (reformat) package sources generate generate Go files by processing source get download and install packages and dependencies install compile and install packages and dependencies list list packages run compile and run Go program test test packages tool run specified go tool version print Go version vet report likely mistakes in packages Use "go help [command]" for more information about a command. Additional help topics: c calling between Go and C buildmode build modes cache build and test caching filetype file types gopath GOPATH environment variable environment environment variables importpath import path syntax packages package lists testflag testing flags testfunc testing functions Use "go help [topic]" for more information about that topic. user@hostname:/usr/bin$
3. So, the problem is how to execute the command without the full path. Basically, the solution is simple. Just add the full path to the environment variable configuration file. Just edit the file where it is normally located in the home folder of the user. Normally, the name of the file is .bashrc. So, the full location of the file is in ‘/home/user/.bashrc’ if the user has an username of ‘user’. Just add the following line to the end of the file :
export GOPATH=/usr/bin/go export PATH=$PATH:$GOPATH
4. After saving the file, execute the following command to reload the environment variable. It is useful so to execute the ‘go’ command without the full path.
user@hostname:/usr/bin$ source /home/user/.bashrc user@hostname:/usr/bin$
5. Next, type the following command to check the environment variable’s value :
user@hostname:/usr/bin$ echo $GOPATH /usr/bin/go user@hostname:/usr/bin$ echo $PATH ...:/usr/bin/go user@hostname:/usr/bin$
6. Finally, execute the ‘go’ command without the full path to prove the solution is working. Type ‘go’ in the command line. If it is working the error message will not appear.