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

dep gets confused by internal git environment variables #1871

@sigma

Description

@sigma

What version of dep are you using (dep version)?

version 0.4.1

What dep command did you run?

~/tmp/gopath/src/github.com/sdboyer/deptestdos
❯ ls
deptestdos.go  README.md

~/tmp/gopath/src/github.com/sdboyer/deptestdos
❯ export GIT_DIR=`pwd`/.git

❯ dep init -v
Getting direct dependencies...
Checked 1 directories for packages.
Found 1 direct dependencies.
Root project is "github.com/sdboyer/deptestdos"
 1 transitively valid internal packages
 1 external packages imported from 1 projects
(0)   ✓ select (root)
(1)	? attempt github.com/sdboyer/deptest with 1 pkgs; 4 versions to try
(1)	    try github.com/sdboyer/deptest@v1.0.0
(1)	✗   unable to update checked out version: fatal: reference is not a tree: ff2948a2ac8f538c4ecd55962e919d1e13e74baf
(1)	  : command failed: [git checkout ff2948a2ac8f538c4ecd55962e919d1e13e74baf]: exit status 128
(1)	    try github.com/sdboyer/deptest@v0.8.1
(1)	✗   unable to update checked out version: fatal: reference is not a tree: 3f4c3bea144e112a69bbe5d8d01c1b09a544253f
(1)	  : command failed: [git checkout 3f4c3bea144e112a69bbe5d8d01c1b09a544253f]: exit status 128
(1)	    try github.com/sdboyer/deptest@v0.8.0
(1)	✗   unable to update checked out version: fatal: reference is not a tree: ff2948a2ac8f538c4ecd55962e919d1e13e74baf
(1)	  : command failed: [git checkout ff2948a2ac8f538c4ecd55962e919d1e13e74baf]: exit status 128
(1)	    try github.com/sdboyer/deptest@master
(1)	✗   unable to update checked out version: fatal: reference is not a tree: 3f4c3bea144e112a69bbe5d8d01c1b09a544253f
(1)	  : command failed: [git checkout 3f4c3bea144e112a69bbe5d8d01c1b09a544253f]: exit status 128
(1)	  ← no more versions of github.com/sdboyer/deptest to try; begin backtrack
  ✗ solving failed

Solver wall times by segment:
     b-source-exists: 517.514251ms
         b-list-pkgs:  11.015016ms
            new-atom:    166.844µs
             satisfy:    108.747µs
         select-root:     68.589µs
     b-list-versions:     30.368µs
               other:     14.179µs
  b-deduce-proj-root:      3.584µs

  TOTAL: 528.921578ms

init failed: unable to solve the dependency graph: Solving failure: No versions of github.com/sdboyer/deptest met constraints:
	v1.0.0: unable to update checked out version: fatal: reference is not a tree: ff2948a2ac8f538c4ecd55962e919d1e13e74baf
: command failed: [git checkout ff2948a2ac8f538c4ecd55962e919d1e13e74baf]: exit status 128
	v0.8.1: unable to update checked out version: fatal: reference is not a tree: 3f4c3bea144e112a69bbe5d8d01c1b09a544253f
: command failed: [git checkout 3f4c3bea144e112a69bbe5d8d01c1b09a544253f]: exit status 128
	v0.8.0: unable to update checked out version: fatal: reference is not a tree: ff2948a2ac8f538c4ecd55962e919d1e13e74baf
: command failed: [git checkout ff2948a2ac8f538c4ecd55962e919d1e13e74baf]: exit status 128
	master: unable to update checked out version: fatal: reference is not a tree: 3f4c3bea144e112a69bbe5d8d01c1b09a544253f
: command failed: [git checkout 3f4c3bea144e112a69bbe5d8d01c1b09a544253f]: exit status 128

What did you expect to see?

dep init should succeed regardless of how the current git repository is handled (in this case, with an explicit $GIT_DIR).
Note that this is exactly what happens when running something like

git rebase -x ./hack/test.bash origin/master

in order to validate a series of commits.

And since some dep tests actually change the repo "under test", this has unfortunate side-effects (an innocent one being your user.name being changed to "Test author" because of gps/vcs_source_test.go, which is... pretty confusing at first)

What did you see instead?

dep gets very confused, and tries to find dependencies' objects in the main repository's $GIT_DIR, despite the fact that it cloned those dependencies elsewhere.
Note that messing with other GIT_* variables leads to different but related failures, so there's a need to selectively cleanup those.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions