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 init fails with "Unable to update checked out version: fatal: reference is not a tree: " #928

Closed maxmeyer closed 6 years ago

maxmeyer commented 7 years ago

What version of Go (go version) and dep (git describe --tags) are you using?

# This is go v1.8.3 directly compiled from source
$ go version
# => go version devel +43afcb5 Wed Mar 15 04:27:49 2017 +0000 linux/amd64
$ git describe --tags
# => v0.1.0-310-g8a46f4d

What dep command did you run?

$ dep init -v
Root project is "git.example.org/project/linebeat"
 7 transitively valid internal packages
 8 external packages imported from 4 projects
(0)   ✓ select (root)
(1)     ? attempt github.com/vjeantet/grok with 1 pkgs; 1 versions to try
(1)         try github.com/vjeantet/grok@master
(1)     ✓ select github.com/vjeantet/grok@master w/1 pkgs
(2)     ? attempt github.com/onsi/gomega with 1 pkgs; 6 versions to try
(2)         try github.com/onsi/gomega@v1.2.0
(2)     ✓ select github.com/onsi/gomega@v1.2.0 w/12 pkgs
(3)     ? attempt gopkg.in/yaml.v2 with 1 pkgs; 1 versions to try
(3)         try gopkg.in/yaml.v2@v2
(3)     ✗   Unable to update checked out version: fatal: reference is not a tree: 25c4ec802a7d637f88d584ab26798e94ad14c13b
(3)       ← no more versions of gopkg.in/yaml.v2 to try; begin backtrack
(2)     ← backtrack: no more versions of github.com/onsi/gomega to try
(2)       ? continue github.com/onsi/gomega with 12 pkgs; 5 more versions to try
(2)         try github.com/onsi/gomega@v1.1.0
(2)     ✓ select github.com/onsi/gomega@v1.1.0 w/12 pkgs
(3)     ? attempt gopkg.in/yaml.v2 with 1 pkgs; 1 versions to try
(3)         try gopkg.in/yaml.v2@v2
(3)     ✗   Unable to update checked out version: fatal: reference is not a tree: 25c4ec802a7d637f88d584ab26798e94ad14c13b
(3)       ← no more versions of gopkg.in/yaml.v2 to try; begin backtrack
(2)     ← backtrack: no more versions of github.com/onsi/gomega to try
(2)       ? continue github.com/onsi/gomega with 12 pkgs; 4 more versions to try
(2)         try github.com/onsi/gomega@v1.0
(2)     ✗   package github.com/onsi/gomega/internal/oraclematcher does not exist within project github.com/onsi/gomega
(2)         try github.com/onsi/gomega@master
(2)     ✓ select github.com/onsi/gomega@master w/12 pkgs
(3)     ? attempt gopkg.in/yaml.v2 with 1 pkgs; 1 versions to try
(3)         try gopkg.in/yaml.v2@v2
(3)     ✗   Unable to update checked out version: fatal: reference is not a tree: 25c4ec802a7d637f88d584ab26798e94ad14c13b
(3)       ← no more versions of gopkg.in/yaml.v2 to try; begin backtrack
(2)     ← backtrack: no more versions of github.com/onsi/gomega to try
(2)       ? continue github.com/onsi/gomega with 12 pkgs; 2 more versions to try
(2)         try github.com/onsi/gomega@gh-pages
(2)     ✗   Unable to update checked out version: fatal: reference is not a tree: 1061b902651e3616625934ec6a60ee32de3e8cc9
(2)         try github.com/onsi/gomega@revert-201-json_formatting
(2)     ✓ select github.com/onsi/gomega@revert-201-json_formatting w/12 pkgs
(3)     ? attempt gopkg.in/yaml.v2 with 1 pkgs; 1 versions to try
(3)         try gopkg.in/yaml.v2@v2
(3)     ✗   Unable to update checked out version: fatal: reference is not a tree: 25c4ec802a7d637f88d584ab26798e94ad14c13b
(3)       ← no more versions of gopkg.in/yaml.v2 to try; begin backtrack
(2)     ← backtrack: no more versions of github.com/onsi/gomega to try
(2)     ← backtrack: no more versions of github.com/onsi/gomega to try
(1)     ← backtrack: no more versions of github.com/vjeantet/grok to try
  ✗ solving failed

Solver wall times by segment:
     b-list-versions: 5.450851536s
         b-list-pkgs: 3.188943643s
              b-gmal: 2.509893212s
  b-deduce-proj-root: 478.182695ms
             satisfy:   3.325385ms
            unselect:   1.805507ms
         select-atom:   1.592507ms
         select-root:   1.335992ms
            new-atom:    331.496µs
           backtrack:    283.635µs
               other:     18.247µs
     b-source-exists:     17.236µs

  TOTAL: 11.636581091s

No versions of gopkg.in/yaml.v2 met constraints:
        v2: Unable to update checked out version: fatal: reference is not a tree: 25c4ec802a7d637f88d584ab26798e94ad14c13b

What did you expect to see?

dep generates the Gopkg.toml and Gopkg.lock

What did you see instead?

No versions of gopkg.in/yaml.v2 met constraints:
        v2: Unable to update checked out version: fatal: reference is not a tree: 25c4ec802a7d637f88d584ab26798e94ad14c13b

Questions

sdboyer commented 7 years ago

hi, welcome! thanks for the issue 😄

Is there a source cache I need to clear? Is there any documentation on this? I used google, but the search was not successful.

there is - it should be at GOPATH/pkg/dep/sources/https-gopkg.in-yaml.v2. however, it's quite odd that this isn't being handled automatically; fetching the most recent version should be something we handle transparently.

could you tell me the output of git log, git status, and git branch -av in that directory?

maxmeyer commented 7 years ago

Hi @sdboyer,

thanks for your help. I attached the files you requested.

git-branch.txt git-log.txt git-status.txt

Is there any documentation about $GOPATH/pkg/dep/sources/https-gopkg.in-yaml.v2. I looked for such a cache, but didn't find it.

sdboyer commented 7 years ago

ah, i don't need the git output from your project, sorry - i need it from what's in $GOPATH/pkg/dep/sources dir. it must be in $GOPATH/pkg/dep/sources/https---github.com-go--yaml-yaml, actually - could you report those three git commands from there?

Is there any documentation about $GOPATH/pkg/dep/sources/https-gopkg.in-yaml.v2. I looked for such a cache, but didn't find it.

there isn't any specific documentation about it, primarily because it's an implementation detail that users, ideally, shouldn't have to worry about. but, we should definitely add just a general FAQ item about the source cache area.

maxmeyer commented 7 years ago

Ah. Sorry. I was just on the wrong machine. I'm going to upload it again.

maxmeyer commented 7 years ago

@sdboyer I'm a bit confused. I just checked the files again. The files given up there, are from within $GOPATH/pkg/dep/sources/https-gopkg.in-yaml.v2. That's not my project. "git.example.org/project/linebeat" is "the" internal project which references yaml.v2 indirectly.

What I can tell is, that after removing the cache, it works now, but this is kinda cumbersome. I attached the newly generated files + the old ones as I backed up the "old" repository of yaml.v2

REF=$(git rev-parse --short HEAD)
git status > /tmp/git-status-$REF.txt
git branch -av > /tmp/git-branch-$REF.txt
git log > /tmp/git-log-$REF.txt

git-branch-25c4ec8.txt git-branch-a3f3340.txt git-log-25c4ec8.txt git-log-a3f3340.txt git-status-25c4ec8.txt git-status-a3f3340.txt

This is the repository causing the issue: https-gopkg.in-yaml.v2.tar.gz

sdboyer commented 7 years ago

What I can tell is, that after removing the cache, it works now, but this is kinda cumbersome.

unfortunately, this means we can't investigate what may have gone wrong there, now 😢 😢 😢

That's not my project. "git.example.org/project/linebeat" is "the" internal project which references yaml.v2 indirectly.

right, ok, brief explanation about what's going on.

the verbose output you see there is the solver trying to find a version of your dependencies that will work, according to various criteria (not an exhaustive list):

  1. their versions meet with declared constraints on them
  2. the imports they have are satisfiable, including the constraints they declare in their own Gopkg.toml (if any)
  3. for all imports into a given package, a package exists at that import path (so, if something imports gopkg.in/yaml.v2/subpkg, it will always fail out because that subpackage does not exist in any versions of `yaml.v2)

both 2 and 3 entail that we actually inspect the source code of yaml.v2. that means checking it out on disk. the fatal: reference is not a tree: 25c4ec802a7d637f88d584ab26798e94ad14c13b message you're seeing coming back from an attempt to do that checkout.

this is kinda cumbersome.

no argument - all of our design is geared towards not requiring the user to know or care about that cache area. we've gotten a lot better at this over the past couple months, but it seems you've found a hole! that's why i was hoping to inspect the state of the problem repository on disk - it might have given us a clue about what went wrong.

maxmeyer commented 7 years ago

nfortunately, this means we can't investigate what may have gone wrong there, now :cry: :cry: :cry:

No. :smile: I made a backup of the whole cache! After I put the old one in place, I get a similar error. Though I've got another package in "that" cache which makes dep init to fail.

No versions of github.com/markbates/grift met constraints:
        master: Unable to update checked out version: fatal: reference is not a tree: 8e706d9b1370e074ed48f3e56b5d29c8b01dd635
sdboyer commented 7 years ago

oh, brilliant! looking forward to more details, then 😀

On August 4, 2017 10:45:15 AM EDT, "Dennis Günnewig" notifications@github.com wrote:

nfortunately, this means we can't investigate what may have gone wrong there, now :cry: :cry: :cry:

No. :smile: I made a backup of the whole cache!

-- You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/golang/dep/issues/928#issuecomment-320267789

maxmeyer commented 7 years ago

But how can I help to identify the problem?

sdboyer commented 7 years ago

oh...wait, when i first responded to that comment, you didn't have the links to the files there. they're there now, i think that's what i need.

i probably won't be able to get back to this for a bit, but it looks like the info we need is there.

maxmeyer commented 7 years ago

Good. I also attached the cached repository as tar.gz-file to the issue. Just in the case you need access to it.

sdboyer commented 6 years ago

closing this one out, as whatever the underlying cause was, #1279 almost certainly has it covered.

darkpssngr commented 6 years ago

Had the same problem. Turns out this was because my project is the GOPATH and I opened the package in intelliJ with gofmt and goimports configured which resulted in all packages checked out in GOPATH/pkg/dep/sources to be formatter causing this problem. Had to add a scope to stop intellJ from running gofmt or goimport on these files.