Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

Dep init fails with "Unable to update checked out version: fatal: reference is not a tree: " #928

Closed
maxmeyer opened this issue Aug 1, 2017 · 13 comments

Comments

@maxmeyer
Copy link

maxmeyer commented Aug 1, 2017

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/[email protected]
(2)     ✓ select github.com/onsi/[email protected] 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/[email protected]
(2)     ✓ select github.com/onsi/[email protected] 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/[email protected]
(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

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

sdboyer commented Aug 2, 2017

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

maxmeyer commented Aug 2, 2017

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

sdboyer commented Aug 2, 2017

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

maxmeyer commented Aug 3, 2017

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

@maxmeyer
Copy link
Author

maxmeyer commented Aug 4, 2017

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

sdboyer commented Aug 4, 2017

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

maxmeyer commented Aug 4, 2017

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

No. 😄 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
Copy link
Member

sdboyer commented Aug 4, 2017 via email

@maxmeyer
Copy link
Author

maxmeyer commented Aug 4, 2017

But how can I help to identify the problem?

@sdboyer
Copy link
Member

sdboyer commented Aug 4, 2017

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

maxmeyer commented Aug 7, 2017

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

@sdboyer
Copy link
Member

sdboyer commented Dec 1, 2017

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

@sdboyer sdboyer closed this as completed Dec 1, 2017
@darkpssngr
Copy link

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.

wking added a commit to wking/openshift-installer that referenced this issue Oct 25, 2018
Generated with:

  $ rm -rf "$(go env GOPATH)/pkg/dep/sources"
  # to avoid errors like "Unable to update checked out version: fatal: reference is not a tree"
  # possibly [1]
  $ dep ensure -update

using:

  $ dep version
  dep:
   version     : v0.5.0
   build date  :
   git hash    : 22125cf
   go version  : go1.10.3
   go compiler : gc
   platform    : linux/amd64
   features    : ImportDuringSolve=false

I haven't reviewed all of these changes, but I want this to pull in
openshift/hive@b1cad987 (contrib/pkg/awstagdeprovision: Allow for OR
filters, 2018-10-18, openshift/hive#47).

[1]: golang/dep#928 (comment)
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

3 participants