golang / dep

Go dependency management tool experiment (deprecated)
https://golang.github.io/dep/
BSD 3-Clause "New" or "Revised" License
12.84k stars 1.05k forks source link

dep doesn't check git remote for new version #719

Closed kjk closed 7 years ago

kjk commented 7 years ago

This is on latest mac, using latest dep 6b75d6b4c7f4b29fa3a125369da18ee0d48175eb

Here's what happened:

$ dep ensure -v
Root project is "github.com/kjk/blog"
 1 transitively valid internal packages
 13 external packages imported from 13 projects
(0)   ✓ select (root)
(1) ? attempt github.com/SparkPost/gosparkpost with 1 pkgs; at least 1 versions to try
(1)     try github.com/SparkPost/gosparkpost@master
(1) ✓ select github.com/SparkPost/gosparkpost@master w/2 pkgs
(2) ? attempt github.com/dustin/go-humanize with 1 pkgs; at least 1 versions to try
(2)     try github.com/dustin/go-humanize@master
(2) ✓ select github.com/dustin/go-humanize@master w/1 pkgs
(3) ? attempt github.com/gorilla/websocket with 1 pkgs; at least 1 versions to try
(3)     try github.com/gorilla/websocket@master
(3) ✓ select github.com/gorilla/websocket@master w/1 pkgs
(4) ? attempt github.com/kjk/siser with 1 pkgs; at least 1 versions to try
(4)     try github.com/kjk/siser@master
(4) ✓ select github.com/kjk/siser@master w/1 pkgs
(5) ? attempt github.com/go-fsnotify/fsnotify with 1 pkgs; at least 1 versions to try
(5)     try github.com/go-fsnotify/fsnotify@master
(5) ✓ select github.com/go-fsnotify/fsnotify@master w/1 pkgs
(6) ? attempt github.com/microcosm-cc/bluemonday with 1 pkgs; at least 1 versions to try
(6)     try github.com/microcosm-cc/bluemonday@master
(6) ✓ select github.com/microcosm-cc/bluemonday@master w/1 pkgs
(7) ? attempt github.com/kjk/dailyrotate with 1 pkgs; at least 1 versions to try
(7)     try github.com/kjk/dailyrotate@master
(7) ✓ select github.com/kjk/dailyrotate@master w/1 pkgs
(8) ? attempt github.com/kurin/blazer with 1 pkgs; at least 1 versions to try
(8)     try github.com/kurin/blazer@master
(8) ✓ select github.com/kurin/blazer@master w/4 pkgs
(9) ? attempt github.com/thomas11/atomgenerator with 1 pkgs; at least 1 versions to try
(9)     try github.com/thomas11/atomgenerator@master
(9) ✓ select github.com/thomas11/atomgenerator@master w/1 pkgs
(10)  ? attempt github.com/kr/fs with 1 pkgs; at least 1 versions to try
(10)      try github.com/kr/fs@master
(10)  ✓ select github.com/kr/fs@master w/1 pkgs
(11)  ? attempt github.com/kjk/u with 1 pkgs; at least 1 versions to try
(11)      try github.com/kjk/u@master
(11)  ✓ select github.com/kjk/u@master w/1 pkgs
(12)  ? attempt github.com/russross/blackfriday with 1 pkgs; at least 1 versions to try
(12)      try github.com/russross/blackfriday@master
(12)  ✓ select github.com/russross/blackfriday@master w/1 pkgs
(13)  ? attempt golang.org/x/crypto with 1 pkgs; at least 1 versions to try
(13)      try golang.org/x/crypto@master
(13)  ✗   Unable to update checked out version: fatal: reference is not a tree: e1a4589e7d3ea14a3352255d04b6f1a418845e5e
(13)      try golang.org/x/crypto@master
(13)  ✗   Unable to update checked out version: fatal: reference is not a tree: e1a4589e7d3ea14a3352255d04b6f1a418845e5e
(13)    ← no more versions of golang.org/x/crypto to try; begin backtrack
(12)  ← backtrack: no more versions of github.com/russross/blackfriday to try
(11)  ← backtrack: no more versions of github.com/kjk/u to try
(10)  ← backtrack: no more versions of github.com/kr/fs to try
(9) ← backtrack: no more versions of github.com/thomas11/atomgenerator to try
(8) ← backtrack: no more versions of github.com/kurin/blazer to try
(7) ← backtrack: no more versions of github.com/kjk/dailyrotate to try
(6) ← backtrack: no more versions of github.com/microcosm-cc/bluemonday to try
(5) ← backtrack: no more versions of github.com/go-fsnotify/fsnotify to try
(4) ← backtrack: no more versions of github.com/kjk/siser to try
(3) ← backtrack: no more versions of github.com/gorilla/websocket to try
(2) ← backtrack: no more versions of github.com/dustin/go-humanize to try
(1) ← backtrack: no more versions of github.com/SparkPost/gosparkpost to try
  ✗ solving failed

Solver wall times by segment:
     b-source-exists: 4.631438607s
         b-list-pkgs: 3.677590715s
              b-gmal:  3.49158557s
  b-deduce-proj-root: 534.542581ms
         select-atom:   1.624344ms
            new-atom:   1.149836ms
             satisfy:     946.35µs
            unselect:    537.982µs
         select-root:    498.242µs
     b-list-versions:    160.935µs
           backtrack:     66.515µs
               other:     15.533µs

  TOTAL: 12.34015721s

ensure Solve(): No versions of golang.org/x/crypto met constraints:
    master: Unable to update checked out version: fatal: reference is not a tree: e1a4589e7d3ea14a3352255d04b6f1a418845e5e

Notice that https://github.com/golang/crypto/commit/e1a4589e7d3ea14a3352255d04b6f1a418845e5e does exist.

I fixed it by doing:

$ go get ./...
$ dep ensure

After updating local copy of all dependencies to latest version, dep ensure works.

I assume that's because dep only checked a local version of github.com/golang/crypto in $GOPATH, which was not up-to-date, but didn't check the remote.

I got into that state because I regularly work on 2 different machines.

I did dep ensure -update on one machine, which stamped the latest version of golang.org/x/crypto.

I did git pull on the second machine and tried dep ensure, which failed due to outdated local copy (I think).

sdboyer commented 7 years ago

Ugh, cases like these should've been resolved with #696.

go get ./... can't have helped, because only dep init touches GOPATH. With only a single, narrow, not-relevant-here exception, dep ensure does not know or care that GOPATH exists. That is:

I assume that's because dep only checked a local version of github.com/golang/crypto in $GOPATH, which was not up-to-date, but didn't check the remote.

This kind of check doesn't happen in dep ensure - the repository it was reading from was at $GOPATH/pkg/dep/sources/https---go.googlesource.com-crypto.

You're 💯 certain you didn't have an older version of dep somehow, when you originally encountered this error?

kjk commented 7 years ago

My bad, you're right. I checked the history of commands and this is probably outdated dep.

Which brings a separate issue: it should be go get -u github.com/golang/dep to install dep, not go get -u github.com/golang/dep/cmd/dep

I have an alias updatedep="go get -u github.com/golang/dep/cmd/dep" in my . bash_profile because I want to be on the latest version.

For quite a while I had the incorrect go get -u github.com/golang/dep (because who's reading docs, really), so I wasn't actually updating dep.

In this particular case I did ran updatedep alias (so I thought I was running the latest version) but it was in a stale shell session that had the old, incorrect alias.

I know that the right command is in the readme but I'm pretty sure other people make the same assumption as I do.

I feel cmd/* pattern is really meant for packages that are mostly libraries that come with helper programs under cmd/.

Packages that are a single program (like dep) should have the program at the top level and have their libraries under pkg/ or some such.