Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

godep: exec: "go": executable file not found in $PATH

Tags:

heroku

go

I trying to deploy my server on heroku and I stuck on step where I should use godep, I spent little time with GO, last two days I had looking how to solve this issue, actually it's a popular issue, but I can't figure out, maybe I did something fundamentally wrong.

I have OS X 10.11.2
My GOPATH - Users/denis/Programming/Golang
My PATH - $GOPATH/bin
I trying to use godep to my project which is placed in $GOPATH/src/backend

in my PATH I have an executable godep file(not .go).

Whole structure of my workplace.

/Golang/
     .bin/
        godep //executable file
     .pkg/
        .darwin-amd64/
             .//other folders/
     .src/
         .github.com/
         .backend/
         .//other folders// 
like image 879
Dennis Zinkovski Avatar asked Mar 31 '16 18:03

Dennis Zinkovski


1 Answers

First, what is the output of this:

$ echo $PATH

It should, at a minimal to run Go projects, have TWO directories in it for:

  • /path/to/go/installation/bin (e.g. /usr/local/go/bin)
  • /path/to/your/GOPATH/bin (e.g. /Users/denis/Programming/Golang/bin)

Your go's installation should be in your PATH already if you followed the Go installation setup.

https://golang.org/doc/install

Since you posted /Users/denis/Programming/Golang, with the capital U, I am going to assume that you are on OS X going forward...

In OS X, and if you used the default install, you can test for Go in your PATH with a simple command:

$ echo $PATH | grep --color=auto "/usr/local/go/bin"

It should print our your entire $PATH and highlight that you have things setup properly. This is because the OS X GoLang installer in the URL above should have modified your PATH to include:

  • /usr/local/go/bin
  • or more specifically, it may be export PATH="$PATH:/usr/local/go/bin"

If you have some custom .bashrc and/or .profile files, then most likely your PATH isn't being setup correctly. You can test this by doing this:

$ export PATH="$PATH:/usr/local/go/bin"
$ export PATH="$PATH:/Users/denis/Programming/Golang/bin"
$ godep go build

If it works now, then your PATH isn't setup properly in your .bashrc/.profile files. That's a different kind of question and can be setup a 1000 different ways and you may need to figure it out (or another SO question).

If that resolves your issue, then you need to follow the godep directions to run godep from your project's root:

$ cd $GOPATH/src/backend/
$ godep save
$ git add Godeps/

godep creates a Godeps directory in the root of the Go project. If you have multiple Go projects/multiple executables, then you need to run godep save on each root of the runtime.

IOW, for each executable you run go build for, you need to run godep save in each directory.

Also, once you move to godep, you want to use it for your build and testing as well:

$ godep go build
$ godep go test
...etc

If that's not the problem (you are running it as stated above), then please update your question with more specifics such as what godep command you are running, where, and what that directorys structure looks like for the root of that project (including the filename with package main and your func main() function).

like image 131
eduncan911 Avatar answered Nov 09 '22 05:11

eduncan911