zinit icon indicating copy to clipboard operation
zinit copied to clipboard

[bug]: ._zinit/ver file cause update from gh-r failed

Open hotleave opened this issue 1 year ago • 1 comments

What happened?

When there actually a new version for fzf, currently 0.35.1, but when execute

zi update junegunn/fzf
Binary release already up to date (version: 0.34.0)

Steps to reproduce

  1. gh-r plugin already installed some day before
  2. wait for new version release
  3. update the plugin

Relevant output

Binary release already up to date (version: x.x.x)

Screenshots and recordings

No response

Operating System & Version

OS: darwin21 | Vendor: apple | Machine: aarch64 | CPU: arm64 | Processor: arm | Hardware: arm64

Zsh version

zsh 5.9 (aarch64-apple-darwin21)

Terminal emulator

xterm-kitty

If using WSL on Windows, which version of WSL

None

Additional context

the plugin was installed before, and there is a 'fzf' file in $plugin_folder/._zinit/ver folder, this file has the current install version of the plugin. when update, it will collect the version info from this file, and cause it failed to load from github release page

zinit-autoload.sh line 1481:

        if [[ $ice[from] == (gh-r|github-rel) ]] {
            {
                ICE=( "${(kv)ice[@]}" )
                .zinit-get-latest-gh-r-url-part "$user" "$plugin" || return $?
            } always {
                ICE=()
            }
        } else {
            REPLY=""
        }

zinit-install.sh line 1493:

    if [[ -z $urlpart ]] {
        local tag_version=${ICE[ver]}
        if [[ -z $tag_version ]]; then
            local releases_url=https://github.com/$user/$plugin/releases/latest
            tag_version="$( { .zinit-download-file-stdout $releases_url || .zinit-download-file-stdout $releases_url 1; } 2>/dev/null | \
                              command grep -m1 -o 'href=./'$user'/'$plugin'/releases/tag/[^"]\+')"
            tag_version=${tag_version##*/}
        fi
        local url=https://github.com/$user/$plugin/releases/expanded_assets/$tag_version
    } else {
        local url=https://$urlpart
    }

tag_version is the content of ver file

to fixed the bug, just need to remove the ver file in $plugin_folder/._zinit

hope this will help some people like me

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

hotleave avatar Dec 20 '22 06:12 hotleave

@hotleave,

Thank you for reporting this bug and apologize for delay in response.

I think the bug fix is relatively straightforward, but writing a z-unit test case will be the hard part.

Given your bug triage, do you have any prior art for the code change? I don't want to step on any toes.

vladdoster avatar Mar 11 '23 11:03 vladdoster