Skip to content
This repository has been archived by the owner on Feb 26, 2019. It is now read-only.

Package not found #517

Closed
ajayamohan opened this issue Sep 23, 2016 · 26 comments
Closed

Package not found #517

ajayamohan opened this issue Sep 23, 2016 · 26 comments

Comments

@ajayamohan
Copy link

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
Copy link
Author

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
Copy link

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
Copy link
Author

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

go get github.com/tools/godep

Ajith

@krisnova
Copy link

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

Cheers

@krisnova
Copy link

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
Copy link

Getting a similar error here:

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

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

@krisnova
Copy link

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

@PandaWhisperer
Copy link

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

@parkr
Copy link

parkr commented Nov 8, 2016

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
Copy link

LeslieK commented Nov 22, 2016

@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
Copy link

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
Copy link

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
Copy link

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
Copy link

@rdixonbhw Thanks! That got me past that difficulty.

@MikeSpreitzer
Copy link

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
Copy link

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

MikeSpreitzer added a commit to MikeSpreitzer/tpr-example that referenced this issue May 2, 2017
Fought through tools/godep#517 to victory.
@carlosonunez
Copy link

carlosonunez commented Jun 9, 2017

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
Copy link

eine commented Jun 21, 2017

@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
Copy link

carlosonunez commented Jun 21, 2017 via email

@jockchou
Copy link

jockchou commented Jul 7, 2017

$ 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
Copy link

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
Copy link

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

@bklau
Copy link

bklau commented Sep 21, 2017

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
Copy link

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

@freeformz
Copy link

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

@qiangli
Copy link

qiangli commented Jul 23, 2018

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests