tools / godep

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

v79 bug "Dep (go.googlesource.com/tools) restored, but was unable to load it with error" #535

Closed ilovezfs closed 7 years ago

ilovezfs commented 7 years ago

Note that the following does not occur with v78, and the cause appears to be https://github.com/tools/godep/commit/f15f6db5da33a4ac48be83e20b9dd838e14f117b.

Expected behavior

godep restore should succeed.

Actual behavior

godep restore fails.

Steps to reproduce behavior

Run the homebrew test block:

  test do
    ENV["GOPATH"] = testpath.realpath
    (testpath/"Godeps/Godeps.json").write <<-EOS.undent
      {
        "ImportPath": "github.com/tools/godep",
        "GoVersion": "go1.7",
        "Deps": [
          {
            "ImportPath": "go.googlesource.com/tools",
            "Rev": "3fe2afc9e626f32e91aff6eddb78b14743446865"
          }
        ]
      }
    EOS
    system bin/"godep", "restore"
    assert File.exist?("src/go.googlesource.com/tools/README")
  end

Error is

==> /usr/local/Cellar/godep/HEAD-f15f6db_1/bin/godep restore
godep: [WARNING]: godep should only be used inside a valid go package directory and
godep: [WARNING]: may not function correctly. You are probably outside of your $GOPATH.
godep: [WARNING]:   Current Directory: /private/tmp/godep-test-20170202-85545-1uu8n5t
godep: [WARNING]:   $GOPATH: /private/tmp/godep-test-20170202-85545-1uu8n5t
godep: Dep (go.googlesource.com/tools) restored, but was unable to load it with error:
    no buildable Go source files in /private/tmp/godep-test-20170202-85545-1uu8n5t/src/go.googlesource.com/tools
godep: Error checking some deps.
/usr/local/Homebrew/Library/Homebrew/debrew.rb:11:in `raise'

godep version output

bash-3.2$ godep version
godep v79 (darwin/amd64/go1.7.5

go version output

bash-3.2$ go version
go version go1.7.5 darwin/amd64

Contents of Godeps.json file

{
  "ImportPath": "github.com/tools/godep",
  "GoVersion": "go1.7",
  "Deps": [
    {
      "ImportPath": "go.googlesource.com/tools",
      "Rev": "3fe2afc9e626f32e91aff6eddb78b14743446865"
    }
  ]
}
freeformz commented 7 years ago

That's not a valid Godeps.json file because the package specified is not a valid go package declaration because it (a) contains no valid *.go files and (b) the packages contained there are actually golang.org/x/tools. So if the file is changed to:

{
  "ImportPath": "github.com/tools/godep",
  "GoVersion": "go1.7",
  "Deps": [
    {
      "ImportPath": "golang.org/x/tools/cover",
      "Rev": "3fe2afc9e626f32e91aff6eddb78b14743446865"
    }
  ]
}

godep restore works properly because the correct namespace for the code is golang.org/x/tools and golang.org/x/tools/cover is an actual go package.

PS: This may have worked in previous versions of godep, but that was purely by accident.

ilovezfs commented 7 years ago

Thanks for the help!