Wednesday, January 16, 2019

How To Deal With Dep Ensure Issue

Symptom:

When we create a new project in golang, we run "dep ensure" and get below error:
dep ensure
Solving failure: No versions of k8s.io/gengo met constraints:
        master: unable to update checked out version: fatal: reference is not a tree: f8a0810f38afb8478882b3835a615aebfda39afa
: command failed: [git checkout f8a0810f38afb8478882b3835a615aebfda39afa]: exit status 128

Solution:

Use "dep ensure -v"  to get debug information and find out which packages have check out issues
In this example, k8s.io/gengo  has issues.

It is very likely  dep cache corrupted on this package when new version of our apps or tools being added 

We need to delete dep cache of k8s.io/gengo

rm -rf  $GOPATH/go/dep/source/https---github.com-kubernetes-gengo

rerun dep ensure