"Command not found" error after installing go-eval

I am trying to run Go interactively.

I want to use go-eval for this, I followed the README instructions:

  • I successfully launched go get github.com/sbinet/go-eval/
  • I ran go-eval , which led to -bash: go-eval: command not found

Some more information:

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

  • echo $GOPATH returns: $HOME/golang

  • whereis go-eval does not return output

  • executing 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)

+10
go macos
source share
5 answers

You need to add GOPATH / bin to PATH.

 PATH="$GOPATH/bin:$PATH" 

Update : Starting with Go 1.8 , by default GOPATH is set to $HOME/go if not installed. Above will not work if GOPATH is not set explicitly.

To install both, add this to your .profile:

 export GOPATH="$HOME/go" PATH="$GOPATH/bin:$PATH" 
+35
source share

Is binary go-eval in $GOPATH/bin ? Do you use the $GOPATH/bin/ command as your working directory? If not, this is probably the problem.

go get and go install binaries (if any) in $GOPATH/bin

Check $GOPATH/bin for the go-eval binary. If it is there, try running it with $GOPATH/bin using ./go-eval . If that works, you are kind.

In the future, if you want to run go binaries found in $GOPATH/bin from anywhere in your shell, add the following to your .bashrc or profile:

export PATH=$PATH:$GOPATH/bin

Then restart the terminal or run . ~/.bashrc . ~/.bashrc or . /etc/profile . /etc/profile

When running go install go-eval, I get:

unable to download package: go-eval package: cannot find the "go-eval" package in any of: / usr / local / go / src / go -eval (from $ GOROOT) $ HOME / golang / src / go-eval ( from $ GOPATH)

You get the above error because go-eval is not located in $HOME/golang/src/go-eval . Running go get github.com/sbinet/go-eval/ load the source in $GOPATH/src/github/sbinet/go-eval/ . If you want to run go install go-eval , you need to specify the package name corresponding to its position in the directory hierarchy in $GOPATH/src .

eg. go install github/sbinet/go-eval

+4
source share

I would like to add this in addition to the answers.

As a useful tip, you can always check your teams with a team that .

For example: that go

If the command is not found, you know that you have a PATH problem that you need to handle first.

You can then focus on finding the command using the find command .

For example: find / -name "go" -print 2> / dev / null

The first slash is the directory to start the search, the argument to -name is the command you are looking for, and -print gets a good result. 2> / dev / null sends the results of directories inaccessible to neverland (null), so you do not need to see a bunch of errors.

Using this process will help you quickly find the appropriate command, and then you can add it to your env PATH variable, and it will become available, as indicated in other answers.

+2
source share

All of the above answers speak for themselves. In addition to those that I would like to add, by default you can only access those commands from the terminal without a binary path whose bin folder is added to the environment variable, be it linux, mac or windows.

Otherwise, you will need to specify the path to the bin folder of this software and the binary name. For example, in your case <path_to_bin_folder>/go-eval .

This is the most common reason why you cannot execute this command directly from the command line. Please remember this and try before searching for answers on the Internet, because this will most likely solve your problem. All you need to know is the installation path.

So, write the following in rc or the profile file for your terminal and save, for 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, the changes will not be reflected immediately. You should find the profile file as above. For this type, source ~/.zshrc . Now you can run the command directly from the command line. Even if the problem persists, try logging out of the terminal session and logging out and then logging in again.

If you want to add the path to the bin folder for other packages, you can add it to the $ PATH environment variable using : So, for example, if you want to add the path to the Java binary, then simply

 export PATH=$PATH:$JAVA_HOME/bin 

It is also recommended that you define the path to the package root folder in a separate environment variable (example $GOPATH="$HOME/go" ). In case the installation path changes in the future, you just need to update the environment variable associated with this binary (for example, just update, $ GOPATH = "newpath"), and your command will work as before, as the change in $ GOPATH will be reflected in $ PATH.

0
source share

This problem occurred when using the command "export PATH =" ~ / go / bin: $ PATH ".

It seems that ~ was causing problems and switching to full path worked.

Instead, try something like this that won't use the tilde:

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

0
source share

All Articles