zinit icon indicating copy to clipboard operation
zinit copied to clipboard

[bug]: ziextract fails for windows binaries

Open anupamsr opened this issue 2 years ago • 4 comments

Describe the bug

zinit fails to fetch fetch binaries for windows as it fails in ziextract, such as when using the example of docker/compose from README.md

Steps to reproduce

  1. Run zini for from'gh-r' as'program' stedolan/jq
  2. ziextract: WARNING: extraction of the archive 'jq-win32.exe' had problems.

Expected behavior

It should download the binary correctly

Screenshots and recordings

...
ziextract: Unpacking the files from: `jq-win32.exe'…
++zinit-message:27> [[ -n '' || -z '' ]]
++zinit-message:28> print -n $'\C-M'
+.zinit-extract-wrapper:4> →zinit-extract
+→zinit-extract:1> chmod a+x -- ./jq-win32.exe
+→zinit-extract:2> cygpath -w /home/srivastavaan/.local/share/zinit/plugins/stedolan---jq
+→zinit-extract:2> ./jq-win32.exe /S '/D=E:\scoop\apps\msys2\2022-06-03\home\srivastavaan\.local\share\zinit\plugins\stedolan---jq'
jq: error: syntax error, unexpected ':', expecting $end (Windows cmd shell quoting issues?) at <top-level>, line 1:
S:/
jq: 1 compile error
+.zinit-extract-wrapper:4> retval=3
+.zinit-extract-wrapper:5> ((  retval == 0  ))
+.zinit-extract-wrapper:10> return 3

Operating System & Version

msys | pc | x86_64 | x86_64 | x86_64 unknown

Zsh version

zsh 5.8 (x86_64-pc-msys)

Terminal emulator

xterm-256color (actually MINTTY shipped with msys2)

If using WSL on Windows, which version of WSL

No response

Additional context

No response

anupamsr avatar Jun 09 '22 10:06 anupamsr

It looks like we assume the exe is an installer and we try to extract it. In case where the exe is actual binary, the command to extract fails.

anupamsr avatar Jun 09 '22 10:06 anupamsr

@anupamsr Do you happen to know if this issue just started occurring?

vladdoster avatar Jun 09 '22 22:06 vladdoster

No, this is the first time I have tried to use zinit on msys2 environment. I was able to fix it on my local machine with this patch:

diff --git a/zinit-install.zsh b/zinit-install.zsh
index 379a2279..593469e4 100644
--- a/zinit-install.zsh
+++ b/zinit-install.zsh
@@ -1810,7 +1810,7 @@ ziextract() {
         ((#i)*.rpm)
             →zinit-extract() { →zinit-check cpio "$file" || return 1; $ZINIT[BIN_DIR]/share/rpm2cpio.zsh "$file" | command cpio -imd --no-absolute-filenames; }
             ;;
-        ((#i)*.exe|(#i)*.pe32)
+        ((#i)*.pe32)
             →zinit-extract() {
                 command chmod a+x -- ./$file
                 ./$file /S /D="`cygpath -w $PWD`"

I am not sure if it will break someone else's workflow. To be honest, I think it is best not to assume that the binary we are trying to extract is an installer which will consume those arguments, but may better minds prevail...

anupamsr avatar Jun 14 '22 05:06 anupamsr

@anupamsr I'll open a PR this week to fix this.

vladdoster avatar Jun 21 '22 18:06 vladdoster