zdharma-continuum / zinit

🌻 Flexible and fast ZSH plugin manager
MIT License
2.93k stars 126 forks source link

[bug]: ziextract fails for windows binaries #306

Open anupamsr opened 2 years ago

anupamsr commented 2 years ago

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 commented 2 years ago

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.

vladdoster commented 2 years ago

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

anupamsr commented 2 years ago

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...

vladdoster commented 2 years ago

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