-
Notifications
You must be signed in to change notification settings - Fork 1k
Update cached source before listing packages #513
Conversation
Prevents the following error when running ======CAROLYN WAS HERE 2======= ======CAROLYN WAS HERE======= ======CAROLYN WAS HERE 2======= ======CAROLYN WAS HERE======= ======CAROLYN WAS HERE 2======= ======CAROLYN WAS HERE======= ======CAROLYN WAS HERE 2======= ======CAROLYN WAS HERE======= ======CAROLYN WAS HERE 2======= ======CAROLYN WAS HERE======= ======CAROLYN WAS HERE 2======= ======CAROLYN WAS HERE======= ======CAROLYN WAS HERE 2======= ======CAROLYN WAS HERE======= and the cache is out of date: Unable to update checked out version: fatal: reference is not a tree: 3084677...
So, first...big relief that this fixes the problem. Stale caches have plagued glide ever since a central cache was introduced, and they were a problem for a while in gps until the most recent refactor. They make for a really nasty, trust-shattering experience, because the problems dep mgmt solves are hard enough to understand without the added possibility of a stale cache confusing everything further. While I don't know the exact paths that would make this occur without some pretty exhaustive testing (the variety in input states to the solver yield a larger state space than I can hold in my head), I'm pretty sure I know the answer here. Basically, it doesn't happen more often because yes, there's a different path that's often followed: when encountering a dependency, IFF the solver thinks that it might need the whole list of versions for it, it'll call The basic motivation for this approach is a performance optimization - if there's already a locked version for a project, and we have it in local cache already, AND the user didn't request an upgrade for it, then then we might be able to make it through the whole solve run without needing to hit the network. If any of these conditions aren't met, though, then we try to gain a little wall time speedup by initiating the network activity in the background (via Most of the time, this is a good guess. But not always. If it's not, then the solver will make more targeted calls when it needs additional data, without having already called I don't know why I neglected to put that last flag on there - probably just an oversight at the time. And because it's quite arduous to test (for all the reasons you've described above), I never wrote a test for this path. But if you read the flags being required in that method, this error should make some sense - we've ensured that we have the latest list of versions from upstream, so the Note that this is only possible with git, because in hg and bzr, |
I'mma follow up with an issue about how we might devise a testing apparatus for this. |
Thank you for the details and pointers! |
@cscatolini fyi |
More generalized solution to #513.
Update cached source before listing packages
More generalized solution to golang#513.
This addresses #484. It does fix the simple case that I was testing against, which I'm able to reliably repeat locally, though wasn't sure how to make this into an integration test because it relies on git shenanigans.
Create go package with a release and push it to github.
Create a go package that imports this dependency and then run
dep init
. This populates the cache with the dependency.Create another release of the dependency and push to github.
Edit the lock and manifest to update to the newest release. Note that this commit hash and tag are not in the local cache.
Run
dep ensure -v -n
to reproduce the following error (with some debugging thrown in):What makes me pause is that I don't understand why this isn't a more common bug considering my repo steps. If you can help me figure out why dep is working fine for most people without this, I'd really appreciate it!
If I understand correctly what dep is doing, getting a list of packages included in a dependency at a particular revision, and then having the latest source code seems like the correct fix. But again, I don't get why this isn't a problem for more people then? 😀