tools / godep

dependency tool for go
http://godoc.org/github.com/tools/godep
BSD 3-Clause "New" or "Revised" License
5.55k stars 455 forks source link

Package not found #517

Closed ajayamohan closed 6 years ago

ajayamohan commented 7 years ago

Expected behavior

godep save identifies all dependencies in a new project and saves the json in the GoDeps folder to be created

Actual behavior

Fails with error - $godep save ./... godep: Package (github.com/kr/logfmt) not found

Steps to reproduce behavior

  1. New Project
  2. Take dependency on go-kit packages
  3. Run GoDep

    godep version output

    $godep version godep v74 (darwin/amd64/go1.7)

    go version output

    $godep version godep v74 (darwin/amd64/go1.7)

    Contents of Godeps.json file

  4. None available - it is a brand new run for a new go-kit microservice
ajayamohan commented 7 years ago

if I manually do, go get: go get github.com/kr/logfmt and then do, a godep save

it works! - Is this still a bug or an operator error on my part?

krisnova commented 7 years ago

Hey @ajayamohan, how did you install godep? Did you compile it yourself?

This looks like you are missing a dependency for godep itself, and the go get workaround you submitted seems to be pulling the dependency and dropping it in your $GOPATH. Which will of course allow godep to build properly.

ajayamohan commented 7 years ago

Hi @kris-nova, I installed godep through the recommended install option:

go get github.com/tools/godep

Ajith

krisnova commented 7 years ago

Okay thanks - will re-create today and get back to you.

Cheers

krisnova commented 7 years ago

Hey @ajayamohan,

This looks like you ran into the problem while installing go-kit? Is that right?

Take dependency on go-kit packages

If so can we open up a new bug in go-kit for this? I think I see the problem, but I want to make sure it gets tracked correctly. Also, if that is the case can we get detailed step-by-step reproduction steps on the go-kit issue?

Thanks :)

PandaWhisperer commented 7 years ago

Getting a similar error here:

godep: Package (golang.org/x/sys/unix) not found

I'm new to go, not sure if related.

krisnova commented 7 years ago

@PandaWhisperer - These are all go dependency errors - how did you install your application, and what are your replication steps?

PandaWhisperer commented 7 years ago

@kris-nova just like the documentation said – go get github.com/tools/godep. Is there anything else to do?

parkr commented 7 years ago

This happened to me recently because the version of godep was mismatched with my go version. This was a problem for me because Homebrew versions GOROOT (e.g. GOROOT="/usr/local/Cellar/go/1.7.3/libexec").

$ go version
go version go1.7.3 darwin/amd64
$ godep version
godep v74 (darwin/amd64/go1.7.1)

I had it installed via Homebrew. Solution was to brew remove godep && go get github.com/tools/godep. Hope this helps someone else!

LeslieK commented 7 years ago

@kris-nova Figured it out! I cloned a repo using 'go get' and then did 'godep save' I got an error that godep could not find a dependency. I got the missing dependency with 'go get' and ran 'godep save' again. I repeated this process for every missing dependency. Eventually, 'godep save' worked. The reason appears to be that go is trying to be efficient: It only imports packages that are appropriate for my OS (ubuntu). godep, on the other hand, is looking for all dependencies, regardless of the value of GOOS. Solution: 'go get' missing dependencies until 'godep save' works.

MikeSpreitzer commented 7 years ago

I tried that, and eventually ran into this roadblock:

mjs10:tpr-example mspreitz$ godep save
godep: Package (github.com/docker/distribution/digest) not found
mjs10:tpr-example mspreitz$ go get github.com/docker/distribution/digest
package github.com/docker/distribution/digest: cannot find package "github.com/docker/distribution/digest" in any of:
    /usr/local/go/src/github.com/docker/distribution/digest (from $GOROOT)
    /Users/mspreitz/Documents/go/src/github.com/docker/distribution/digest (from $GOPATH)
rdixonbhw commented 7 years ago

It's probably looking at the master branch which no longer has a digest directory (blame docker), maybe try manually checking out https://github.com/docker/distribution/tree/release/2.6 in your $GOPATH and then running godep save in your project.

MikeSpreitzer commented 7 years ago

Starting from a fresh installation of go 1.8.1 and an empty go workspace:

mjs10:~ mspreitz$ printenv GOPATH
/Users/mspreitz/Documents/go2

mjs10:~ mspreitz$ ls -l ${GOPATH}/*
/Users/mspreitz/Documents/go2/bin:

/Users/mspreitz/Documents/go2/pkg:

/Users/mspreitz/Documents/go2/src:

mjs10:~ mspreitz$ printenv GOROOT
/usr/local/go

mjs10:~ mspreitz$ ls -l $GOROOT/bin
total 55544
-rwxr-xr-x  1 root  wheel   9985940 Apr  7 12:54 go
-rwxr-xr-x  1 root  wheel  15129860 Apr  7 12:59 godoc
-rwxr-xr-x  1 root  wheel   3320448 Apr  7 12:54 gofmt

mjs10:~ mspreitz$ go version
go version go1.8.1 darwin/amd64

mjs10:~ mspreitz$ go get github.com/tools/godep

mjs10:~ mspreitz$ printenv | grep GO
GOROOT=/usr/local/go
GOPATH=/Users/mspreitz/Documents/go2

mjs10:~ mspreitz$ which godep
/Users/mspreitz/Documents/go2/bin/godep
mjs10:~ mspreitz$ sudo cp /Users/mspreitz/Documents/go2/bin/godep ${GOROOT}/bin
Password:

mjs10:~ mspreitz$ ls -l $GOROOT/bin
total 73792
-rwxr-xr-x  1 root  wheel   9985940 Apr  7 12:54 go
-rwxr-xr-x  1 root  wheel   9340372 May  2 15:54 godep
-rwxr-xr-x  1 root  wheel  15129860 Apr  7 12:59 godoc
-rwxr-xr-x  1 root  wheel   3320448 Apr  7 12:54 gofmt

mjs10:~ mspreitz$ go get github.com/MikeSpreitzer/tpr-example

mjs10:~ mspreitz$ go version
go version go1.8.1 darwin/amd64

mjs10:~ mspreitz$ godep version
godep v79 (darwin/amd64/go1.8.1)

mjs10:~ mspreitz$ cd /Users/mspreitz/Documents/go2/src/github.com/MikeSpreitzer/tpr-example/

mjs10:tpr-example mspreitz$ godep save
godep: Package (github.com/PuerkitoBio/purell) not found

mjs10:tpr-example mspreitz$ go get github.com/PuerkitoBio/purell

mjs10:tpr-example mspreitz$ godep save
godep: Package (github.com/davecgh/go-spew/spew) not found

mjs10:tpr-example mspreitz$ go get github.com/davecgh/go-spew/spew

mjs10:tpr-example mspreitz$ godep save
godep: Package (github.com/docker/distribution/digest) not found

mjs10:tpr-example mspreitz$ go get github.com/docker/distribution/digest
package github.com/docker/distribution/digest: cannot find package "github.com/docker/distribution/digest" in any of:
    /usr/local/go/src/github.com/docker/distribution/digest (from $GOROOT)
    /Users/mspreitz/Documents/go2/src/github.com/docker/distribution/digest (from $GOPATH)
MikeSpreitzer commented 7 years ago

@rdixonbhw Thanks! That got me past that difficulty.

MikeSpreitzer commented 7 years ago

Next up:

mjs10:tpr-example mspreitz$ godep save
godep: Package (github.com/emicklei/go-restful/swagger) not found
mjs10:tpr-example mspreitz$ 
mjs10:tpr-example mspreitz$ go get github.com/emicklei/go-restful/swagger
package github.com/emicklei/go-restful/swagger: cannot find package "github.com/emicklei/go-restful/swagger" in any of:
    /usr/local/go/src/github.com/emicklei/go-restful/swagger (from $GOROOT)
    /Users/mspreitz/Documents/go2/src/github.com/emicklei/go-restful/swagger (from $GOPATH)
MikeSpreitzer commented 7 years ago

Found that referenced in client-go's Godeps, with a commit ID. Checking out that commit got me past that one.

carlosonunez commented 7 years ago

I wrote a small bash script to automate this for those interested:

missing_package="start"
while [ "$missing_package" != "" ]
do
  missing_package=$(godep save 2>&1 | \
    egrep '^godep: Package (.*) not found' | \
    sed 's/.*(\(.*\)).*/\1/'); 
 [ "$missing_package" != "" ] && { 
   echo "Installing missing package: ${missing_package}" ; 
   go get -u "${missing_package}"
  }
done
godep save
eine commented 7 years ago

@carlosonunez , thank you. That script worked for me. Although I had to add ./... to godep save:

godep_save() {
  missing_package="start"
  while [ "$missing_package" != "" ]
   do
    missing_package=$(godep save $@ 2>&1 | \
      egrep '^godep: Package (.*) not found' | \
      sed 's/.*(\(.*\)).*/\1/'); 
   [ "$missing_package" != "" ] && { 
     echo "Installing missing package: ${missing_package}" ; 
     go get -u "${missing_package}"
    }
  done  
  godep save $@
}
carlosonunez commented 7 years ago

No problem! I'm glad I could help.

Sent from my iPhone

On Jun 20, 2017, at 20:10, 1138-4EB notifications@github.com wrote:

@carlosonunez , thank you. That script worked for me. Although I had to add ./... to godep save:

godep_save() { missing_package="start" while [ "$missing_package" != "" ] do missing_package=$(godep save $@ 2>&1 | \ egrep '^godep: Package (.) not found' | \ sed 's/.((.))./\1/'); [ "$missing_package" != "" ] && { echo "Installing missing package: ${missing_package}" ; go get -u "${missing_package}" } done
godep save $@ } — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

jockchou commented 7 years ago
$ ll
total 8601
drwxr-xr-x 1 jockc 197609       0 7月   8 00:08 conf/
-rwxr-xr-x 1 jockc 197609 8793600 7月   8 06:02 contentlibs.exe*
drwxr-xr-x 1 jockc 197609       0 7月   7 23:09 doc/
drwxr-xr-x 1 jockc 197609       0 7月   8 06:03 Godeps/
-rw-r--r-- 1 jockc 197609    1065 7月   6 04:59 LICENSE
-rw-r--r-- 1 jockc 197609     345 7月   8 05:30 main.go
drwxr-xr-x 1 jockc 197609       0 7月   8 05:32 module/
-rw-r--r-- 1 jockc 197609      70 7月   6 04:59 README.md
drwxr-xr-x 1 jockc 197609       0 7月   8 05:33 utils/
drwxr-xr-x 1 jockc 197609       0 7月   8 06:03 vendor/

jockc@DESKTOP-MDSE3EM MINGW64 ~/go/src/contentlibs (master)
$ pwd
/c/Users/jockc/go/src/contentlibs
$ godep go build
main.go:4:2: cannot find package "contentlibs/module" in any of:
        D:\Go\src\contentlibs\module (from $GOROOT)
        C:\Users\jockc\go\src\contentlibs\Godeps\_workspace\src\contentlibs\module (from $GOPATH)
main.go:6:2: cannot find package "github.com/go-martini/martini" in any of:
        D:\Go\src\github.com\go-martini\martini (from $GOROOT)
        C:\Users\jockc\go\src\contentlibs\Godeps\_workspace\src\github.com\go-martini\martini (from $GOPATH)
main.go:7:2: cannot find package "github.com/martini-contrib/render" in any of:
        D:\Go\src\github.com\martini-contrib\render (from $GOROOT)
        C:\Users\jockc\go\src\contentlibs\Godeps\_workspace\src\github.com\martini-contrib\render (from $GOPATH)
godep: go exit status 1
Sikandarkhan commented 6 years ago

I am getting this error. How can I proceed to solve this now ?

go get github.com/tools/godep package github.com/tools/godep: cannot download, ### $GOPATH not set. For more details see: go help gopath

MikeSpreitzer commented 6 years ago

@Sikandarkhan: that is a basic issue about using the go tools. See https://golang.org/doc/code.html

bklau commented 6 years ago

Any workaround to allow me to do "godep save ./..."? I hit the error "godep: package (github.com/docker/distribution/digest) not found" I build alright but just failed at "godep save ./..."

yincongcyincong commented 6 years ago

@PandaWhisperer do you solve the problem, i have a same one

freeformz commented 6 years ago

I am closing this issue because the repo is going to be archived.

qiangli commented 6 years ago

It worked again for me after removing and reinstalling godep. Likely a mismatch of verions of go and godep after my MacOS upgrade.