Error "command not found" after installing go-eval

Viewed 50742

I'm trying to run Go in an interactive mode.

I want to use go-eval for that, I followed their README instructions:

  • I ran go get github.com/sbinet/go-eval/ successfully
  • I ran go-eval which resulted in -bash: go-eval: command not found

Some more information:

  • echo $PATH returns: /usr/local/go/bin:...

  • echo $GOPATH returns: $HOME/golang

  • running whereis go-eval returns no output

  • running go install go-eval returns:

    can't load package: package go-eval: cannot find package "go-eval" in any of: /usr/local/go/src/go-eval (from $GOROOT) $HOME/golang/src/go-eval (from $GOPATH)

6 Answers

Ran into this issue while using export PATH="~/go/bin:$PATH".

Seems the ~ was causing problems and changing to the full path worked.

Try something like this instead, which won't use a tilde:

export PATH="$HOME/go/bin:$PATH"

All above answers are self explaining. Over and above those I would like to add that by default you can access only those commands from terminal without path to binary whose bin folder is added to the environment variable, be it linux, mac or windows.

Else you will have to specify the path to bin folder of that software followed by the binary name. For instance in your case <path_to_bin_folder>/go-eval.

This is the most common reason that you are not able to execute that command directly from the command line. Please remember this and try this before searching for answers online because this will most probably solve your issue. All you have to know is the installation path.

So, write the following into the rc or profile file for your terminal and save, example for zsh it is ~/.zshrc, for bash it is ~/.bash_profile or ~/.bash_rc.

export GOPATH="$HOME/go"
export PATH=$PATH:$GOPATH/bin

Now although the file is saved but the changes will not reflect immediately. You have to source the profile file as mentioned above. For this type source ~/.zshrc. You should now be able to run the command directly from command line now. Even if the problem still persists try quit the terminal session and logging off and then logging in.

In case you want to add path to bin folder for other packages, you can append it to the $PATH environment variable using :. So for example if you want to add path to java binary as well, then just do

export PATH=$PATH:$JAVA_HOME/bin

Also it is a good practice to define the path to root folder of a package in its separate environment variable(example $GOPATH="$HOME/go"). In case if the installation path changes in future then you'll just have to update the environment variable related to that binary (example just update, $GOPATH="newpath") and your command will work as previously, since the change in $GOPATH will reflect in $PATH.

  1. add those line in to ~/.zshrc

    export GOPATH="$HOME/go"

    export PATH=$PATH:$GOPATH/bin

  2. run source ~/.zshrc

Related