getantibody / antibody

The fastest shell plugin manager.
http://getantibody.github.io
MIT License
1.68k stars 62 forks source link

antibody unable to update #343

Closed sumanthratna closed 4 years ago

sumanthratna commented 4 years ago

Here's my plugins.txt:

zsh-users/zsh-syntax-highlighting

antibody bundle < plugins.txt > .plugins.sh results in:

source /Users/suman/Library/Caches/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-syntax-highlighting/zsh-syntax-highlighting.plugin.zsh
fpath+=( /Users/suman/Library/Caches/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-syntax-highlighting )

antibody update fails with the following error:

Updating all bundles in /Users/suman/Library/Caches/antibody...
antibody: updating: https://github.com/zsh-users/zsh-syntax-highlighting
antibody: git update failed for /Users/suman/Library/Caches/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-syntax-highlighting  
antibody: error: failed to update: object not found
caarlos0 commented 4 years ago

Which antibody version?

sumanthratna commented 4 years ago

antibody version 5.0.0 (installed via brew)

caarlos0 commented 4 years ago

hmm weird, can you give me the output of

cd /Users/suman/Library/Caches/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-syntax-highlighting

git rev-parse --abbrev-ref HEAD
git rev-parse HEAD

?

sumanthratna commented 4 years ago

the git rev-parse HEAD command printed 1a752da1c2f58bd96e1e09a83f53556060674f3f.

caarlos0 commented 4 years ago

and git rev-parse --abbrev-ref HEAD?

sumanthratna commented 4 years ago

it didn't output anything

EDIT: it actually printed master, sorry for the confusion

caarlos0 commented 4 years ago

hmm so that's the problem I think...

sumanthratna commented 4 years ago

My bad, the directory didn't fit in my terminal so I didn't see the output the first time around. git rev-parse --abbrev-ref HEAD outputted master.

ljupchokotev commented 4 years ago

I have the same issue:

antibody: git update failed for /home/bubo/.cache/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-robbyrussell-SLASH-oh-my-zsh  
antibody: git update failed for /home/bubo/.cache/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-completions  
antibody: error: failed to update: object not found

Running the above commands:

❯ git rev-parse --abbrev-ref HEAD
master
❯ git rev-parse HEAD
a6e641b977373740e9744182e6fad9af9ff39bc5

EDIT: I don't even have zsh-completions directly in my zsh_plugins.txt, but it's probably picked up as a dependency? zsh_plugins.txt:

djui/alias-tips
mafredri/zsh-async
rupa/z

hlissner/zsh-autopair
changyuheng/fz
Tarrasch/zsh-bd

zimfw/completion
zimfw/input
zimfw/environment
zimfw/utility

romkatv/powerlevel10k
zdharma/fast-syntax-highlighting
zsh-users/zsh-history-substring-search
jonleopard commented 4 years ago

Getting a similar issue as well:

antibody: git update failed for /Users/jon/Library/Caches/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-completions
antibody: error: failed to update: object not found

Output of that directory:

$ git rev-parse --abbrev-ref HEAD
master

$ git rev-parse HEAD
a6e641b977373740e9744182e6fad9af9ff39bc5
ljupchokotev commented 4 years ago

I just deleted everything from ~/.cache/antibody/ and ran:

antibody bundle < ~/.zsh_plugins.txt >! ~/.zsh_plugins.sh
antibody update

Now everything is correctly cloned and working. Running antibody update again doesn't produce an error.

❯ antibody update
Updating all bundles in /home/bubo/.cache/antibody...
antibody: updating: https://github.com/zdharma/fast-syntax-highlighting
antibody: updating: https://github.com/mafredri/zsh-async
antibody: updating: https://github.com/hlissner/zsh-autopair
antibody: updating: https://github.com/rupa/z
antibody: updating: https://github.com/changyuheng/fz
antibody: updating: https://github.com/djui/alias-tips
antibody: updating: https://github.com/Tarrasch/zsh-bd
antibody: updating: https://github.com/romkatv/powerlevel10k
antibody: updating: https://github.com/zimfw/completion
antibody: updating: https://github.com/zimfw/environment
antibody: updating: https://github.com/zimfw/input
antibody: updating: https://github.com/zimfw/utility
antibody: updating: https://github.com/zsh-users/zsh-history-substring-search

It seems that the failing plugins were some that I might have used previously but never cleaned up by antibody. So it tried to fetch updates for all cloned repos in .cache/antibody/ and not only the plugins I have in my zsh_plugins.txt file.

caarlos0 commented 4 years ago

do you folks have go installed? if so, can you help me debug this?

package main

import (
    "bytes"
    "flag"
    "log"

    "gopkg.in/src-d/go-git.v4"
)

func handlerr(err error) {
    if err != nil {
        panic(err)
    }
}

func main() {
    folder := flag.String("dir", ".", "")
    flag.Parse()

    repo, err := git.PlainOpen(*folder)
    handlerr(err)
    log.Println("opened repo", *folder)

    ref, err := repo.Head()
    handlerr(err)
    log.Printf("ref: %+v\n", ref)

    wt, err := repo.Worktree()
    handlerr(err)

    var w bytes.Buffer
    if err := wt.Pull(&git.PullOptions{
        RemoteName:        "origin",
        ReferenceName:     ref.Name(),
        SingleBranch:      true,
        Depth:             1,
        RecurseSubmodules: 1,
        Progress:          &w,
        Force:             true,
    }); err != git.NoErrAlreadyUpToDate {
        log.Println("update failed for", *folder, w.String())
        handlerr(err)
    }
    log.Println("updated: ", w.String())
}

put it as main.go somewhere, and then:

go run main.go -dir $PATH_TO_BROKEN_PLUGIN 
# eg: /home/bubo/.cache/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-robbyrussell-SLASH-oh-my-zsh

and paste it here...

caarlos0 commented 4 years ago

if you need I can provide the binaries as well

caarlos0 commented 4 years ago

It seems that the failing plugins were some that I might have used previously but never cleaned up by antibody. So it tried to fetch updates for all cloned repos in .cache/antibody/ and not only the plugins I have in my zsh_plugins.txt file.

yes, this is what it does... I'm thinking some old version of antibody cloned some plugins in a funky way and its causing this now...

you can always workaround with rm -rf "$(antibody home)"

ljupchokotev commented 4 years ago

Good thing that my main language is Go :) I will try it out and come back.

caarlos0 commented 4 years ago

BTW: if anyone wants to zip a broken plugin and upload here that also helps a lot! thanks!

ljupchokotev commented 4 years ago

This is the output:

2020/03/23 15:46:01 opened repo /home/bubo/.local/share/Trash/files/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-completions
2020/03/23 15:46:01 ref: a6e641b977373740e9744182e6fad9af9ff39bc5 refs/heads/master
2020/03/23 15:46:01 update failed for /home/bubo/.local/share/Trash/files/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-completions 
panic: object not found

goroutine 1 [running]:
main.handlerr(...)
    /tmp/anti/main.go:13
main.main()
    /tmp/anti/main.go:43 +0x711
exit status 2
sumanthratna commented 4 years ago

It seems that the failing plugins were some that I might have used previously but never cleaned up by antibody. So it tried to fetch updates for all cloned repos in .cache/antibody/ and not only the plugins I have in my zsh_plugins.txt file.

yes, this is what it does... I'm thinking some old version of antibody cloned some plugins in a funky way and its causing this now...

you can always workaround with rm -rf "$(antibody home)"

Note to others (if you're on a mac):

  1. rm -rf "$(antibody home)"
  2. mdkir ~/Library/Caches/antibody
  3. antibody bundle < ~/.zsh_plugins.txt > ~/.zsh_plugins.sh
  4. antibody update
sumanthratna commented 4 years ago

This is the output:

2020/03/23 15:46:01 opened repo /home/bubo/.local/share/Trash/files/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-completions
2020/03/23 15:46:01 ref: a6e641b977373740e9744182e6fad9af9ff39bc5 refs/heads/master
2020/03/23 15:46:01 update failed for /home/bubo/.local/share/Trash/files/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-completions 
panic: object not found

goroutine 1 [running]:
main.handlerr(...)
  /tmp/anti/main.go:13
main.main()
  /tmp/anti/main.go:43 +0x711
exit status 2

And if the clear-cache workaround is used, this is the output:

2020/03/23 10:48:22 opened repo /Users/suman/Library/Caches/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-syntax-highlighting
2020/03/23 10:48:22 ref: d1802e388e94aca25380a3a9aeb4a2b7ba661b41 refs/heads/master
2020/03/23 10:48:23 updated:
caarlos0 commented 4 years ago

@sumanthratna can you zip that plugin folder and upload here? I'll need to look into it 🤔

caarlos0 commented 4 years ago

v5 uses go-git, so that's probably the issue, but I need to see what exactly is causing it 🤔

sumanthratna commented 4 years ago

@sumanthratna can you zip that plugin folder and upload here? I'll need to look into it 🤔

I was going to upload the zip but I applied the workaround, so now the plugin works ://. I'll send it anyway, in case it helps.

https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-syntax-highlighting.zip

caarlos0 commented 4 years ago

thanks!

caarlos0 commented 4 years ago

oh, you don't have the previous broken version anymore?

sumanthratna commented 4 years ago

No, I don't have it, sorry. I made the mistake of using rm -rf instead of moving to trash.

caarlos0 commented 4 years ago

no problem, maybe someone else has it still.

I'm thinking maybe we can make thing simpler and just use

package main

import (
    "bytes"
    "flag"
    "log"

    "gopkg.in/src-d/go-git.v4"
)

func handlerr(err error) {
    if err != nil {
        panic(err)
    }
}

func main() {
    folder := flag.String("dir", ".", "")
    flag.Parse()

    repo, err := git.PlainOpen(*folder)
    handlerr(err)

    wt, err := repo.Worktree()
    handlerr(err)

    var w bytes.Buffer
    if err := wt.Pull(&git.PullOptions{
        RemoteName:        "origin",
        Progress:          &w,
    }); err != git.NoErrAlreadyUpToDate {
        log.Println("update failed for", *folder, w.String())
        handlerr(err)
    }
    log.Println("updated: ", w.String())
}

instead (removed a bunch of pull options)...

ljupchokotev commented 4 years ago

I can send it to you, my rm is aliased to safe-rm.

Zip: https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-completions.zip

caarlos0 commented 4 years ago

thankkkkkks!

caarlos0 commented 4 years ago

seems like https://github.com/go-git/go-git/pull/5

caarlos0 commented 4 years ago

I think some plugins were maybe force pushed, and that's causing the issue... git probably handles it better than go-git 🤔

caarlos0 commented 4 years ago

~/Downloads/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-completions master ⇣⇡
λ git pull
From https://github.com/zsh-users/zsh-completions
 * [new tag]         0.31.0     -> 0.31.0
fatal: refusing to merge unrelated histories

not really, I think previous antibody was just eating the error somewhere...

ljupchokotev commented 4 years ago

@caarlos0 should plugins not in zsh_plugins.txt be deleted from antibody's home directory when running antibody update? I had a lot of directories in antibody's home that weren't in my zsh_plugins.txt.

caarlos0 commented 4 years ago

@caarlos0 should plugins not in zsh_plugins.txt be deleted from antibody's home directory when running antibody update? I had a lot of directories in antibody's home that weren't in my zsh_plugins.txt.

antibody doesn't know about the zsh_plugins.txt when updating... that's why it updates everything there...

caarlos0 commented 4 years ago

releasing v5.0.1 which will have a more detailed error message about this...

caarlos0 commented 4 years ago

closing as it was actually a bug on previous versions...

thanks for the help everyone! 🚀

caarlos0 commented 4 years ago

ok this just happened with a repo that didn't had any force-push...

I give up, will revert to os.exec git.