Masterminds / glide

Package Management for Golang
https://glide.sh
Other
8.15k stars 540 forks source link

Update failed for ... contains uncommitted changes. Skipping update #398

Open ansel1 opened 8 years ago

ansel1 commented 8 years ago

My project was converted to glide last week. Everything was fine then. I vendored using the glide update --delete --force -u -s -v command. I check my dependencies in to source control, so I was using the options to string nested vendor folders and VCS files.

This week, I added a new dependency to glide.yml, and tried running glide update --delete --force -u -s -v again. Some of the dependencies failed with the message above.

If I delete those dependencies from the vendor folder, then update, it works. Interestingly, some of the dependencies giving me trouble have new versions matching my glide.yml constraints, but not all. Some dependencies which gave that error message do not have new available versions, and other dependencies were updated to new versions without the error.

mattfarina commented 8 years ago

@ansel1 I saw this once before when there were uncommitted changes to your project that pulls in the dependencies. I ran into it myself and then somehow it went away before I could duplicate it. Have you tried a fresh clone of your project? Do VCS metadata directories exist in those projects (e.g., .git directories). If so, try deleting them.

We are working on some changes that will take the possibility of an error like this away completely.

ansel1 commented 8 years ago

Unfortunately, I worked around the problem by deleting the affected dependencies from the vendor folder. Since then it hasn't happened again. I did have uncommitted changes in my local repo. I'm not sure about the nested VCS folders under vendor. I think maybe glide, when you update, puts all those folders back, resolves everything, then deletes them again. Is that right? If that's the case, it's possible there were some VCS folders there, because I think the error message was causing glide to bomb out before it stripped the VCS folders back out.

wchrisjohnson commented 8 years ago

I just hit this issue.

I had gone thru my glide.yaml file and added version: entries for all of the packages that didnt have them, based on the glide.lock file. I got a bunch of errors like the above. I cleared out the vendor folder with rm -rf vendor and tried again. This time it worked, but there was a huge number of changes when I did a `git status'. When I looked deeper, every change was in a package that was a dependency of one of my packages.

So, the questions are: am I using Glide incorrectly? If not, should I add dependencies of my packages to my glide.yaml file and version them in there too?

wchrisjohnson commented 8 years ago

I should add that I am now in good shape. I ended up basically taking my last good glide.lock file, and using that as a reference to pin all packages in my Glide.yaml file. This includes dependencies of the packages I need in my app. Once I did that, I was able to glide up -u -s. git now shows the only thing changed is my glide.yaml and glide.lock, and the only changes in the .lock file are a very few packages that I had missed because they were testing related.

maleck13 commented 8 years ago

When this happend to me, it was after I had ran go fmt ./... which also formatted the vendor files and modified them. Then when I next ran glide get <some dep> it failed on the dependencies that had been modified. Adding this incase it helps someone else

wchrisjohnson commented 8 years ago

Oh cool - that's great to know. I use Atom with a plugin that does a variety of these kinds of things with every save. I should def check to be sure I'm excluding the vendor folder if possible.

fiatjaf commented 8 years ago

I'm seeing this after amending a commit in another package on my machine, which is a dependency of the project where glide is being used.

After trying to manually set the version number on glide.lock, I've tried deleting the entire ./vendor directory, remove all references to the package from glide.yaml and glide.lock and install it back with glide get. It shows the same error. I've erased the package from my machine and tried to make glide fetch it directly from GitHub: same error. It doesn't make sense.

For the record, the package is https://github.com/fiatjaf/hyperscript-go/commit/6e2a0bea670221cd63d1f304f66708e728698f5c.

raboof commented 8 years ago

I'm having the same issue, also after removing my glide.lock and complete vendor folder...

raboof commented 8 years ago

Fixed it by clearing out $HOME/.glide/cache/. Might have had to do with either:

fiatjaf commented 8 years ago

I also did a git push -f.

raboof commented 8 years ago

@fiatjaf in that case it sounds like our issue (the ~/.glide/cache not responding well to git push -f'd repos) might have been separate from the original issue that started this thread - perhaps we should file separately?

sdboyer commented 8 years ago

Hmm, yeah, it does sound like the issue might be with glide not pulling in force-pushed tag changes as it should. Will have to investigate...

kylev commented 7 years ago

Maybe it happens when your upstream package force pushes? I ran into this today using echo.

glide.yml:

package: github.com/redacted/thingy
import:
- package: github.com/labstack/echo
  version: ^3.0.0

Glide is cranky:

bash$  glide install
[INFO]  Lock file (glide.lock) does not exist. Performing update.
[INFO]  Downloading dependencies. Please wait...
[INFO]  --> Fetching updates for github.com/labstack/echo.
[ERROR] Update failed for github.com/labstack/echo: github.com/labstack/echo contains uncommitted changes. Skipping update
[ERROR] Failed to do initial checkout of config: github.com/labstack/echo contains uncommitted changes. Skipping update

Over in ~/.glide/cache/src/https-github.com-labstack-echo something had massively re-arranged things:

bash$ git status
On branch v3
Your branch and 'origin/v3' have diverged,
and have 1 and 6 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)
You have unmerged paths.
  (fix conflicts and run "git commit")
  (use "git merge --abort" to abort the merge)

Changes to be committed:

    modified:   .gitignore
    modified:   context.go
    modified:   context_test.go
    modified:   middleware/cors.go
    modified:   middleware/cors_test.go
    modified:   router.go
    modified:   router_test.go
    modified:   website/Makefile
    modified:   website/config.json
    modified:   website/content/guide/customization.md
    modified:   website/content/guide/faq.md
    modified:   website/content/guide/installation.md
    deleted:    website/content/guide/migrating.md
    new file:   website/content/guide/migration.md
    modified:   website/content/middleware/cors.md
    modified:   website/layouts/partials/footer.html
    modified:   website/layouts/partials/head.html
    modified:   website/layouts/partials/sidenav.html
    new file:   website/static/scripts/main.js

Unmerged paths:
  (use "git add <file>..." to mark resolution)

    both modified:   README.md
    both modified:   website/content/index.md

Sure enough, the git log last commit that I have is f41453 with the summary line "updated docs, readme and benchmark tests (#718)". That is now 0fca54 on the v3 branch.

At least in my case, it appears to support the amend/force-push patterns mentioned.

zwass commented 7 years ago

I am also experiencing this issue, which seems likely to be due to a force push on the remote.

Deleting ~/.glide/cache/offending_repo.git seems to fix the problem on the next glide install.

Eriner commented 7 years ago

In the same boat as @zwass and others here. Deleting the cache fixed the issue after I force-pushed one of my packages.

homme commented 7 years ago

git checkout -b new-branch triggered this issue for me. Deleting and repopulating ~/.glide/cache solved it. My .gitignore is as follows:

$ cat .gitignore 
vendor/*
.glide/*
stevecrozz commented 7 years ago

glide cc fixes my setup, seems slightly less aggressive deleting the cache folder manually although it might be exactly the same thing in the end.

veqryn commented 7 years ago

Git symlinks on windows also cause this error message to come up, forcing me to delete my .glide folder every time I want to update my vendor directory. See example here: https://github.com/prometheus/procfs/issues/60

tranhung301293 commented 6 years ago

I also met this issue and I solve it by using "git reset --hard" to remove modified file by origin file. Hope it help