visual-studio-codezipmarketplace

VSCode Marketplace extension: Corrupt ZIP: end of central directory record signature not found


I am trying to install a VSIX package downloaded from the Marketplace using wget on a Linux VM where the VSCode server is installed but I am getting the below error:

$ wget -nv https://marketplace.visualstudio.com/_apis/public/gallery/publishers/llvm-vs-code-extensions/vsextensions/vscode-clangd/latest/vspackage -o vspackage.vsix
$ code --install-extension vspackage.vsix
Installing extensions on SSH: boozy-olive-harrier...
Corrupt ZIP: end of central directory record signature not found
Failed Installing Extensions: vscode-remote://ssh-remote%2Bboozy-olive-harrier/root/vspackage.vsix

Downloading the file with Firefox on Windows and using the "Install from VSIX..." button inside the VSCode client (ref) works as expected.

The URL I am using is this one: https://marketplace.visualstudio.com/_apis/public/gallery/publishers/llvm-vs-code-extensions/vsextensions/vscode-clangd/latest/vspackage

I compared the md5sum of the downloaded files and I don't get the same if I download the file from Windows or Linux:

Linux VM:

$ wget -nv https://marketplace.visualstudio.com/_apis/public/gallery/publishers/llvm-vs-code-extensions/vsextensions/vscode-clangd/latest/vspackage
2021-02-09 16:50:08 URL:https://marketplace.visualstudio.com/_apis/public/gallery/publishers/llvm-vs-code-extensions/vsextensions/vscode-clangd/latest/vspackage [1270960/1270960] -> "vspackage" [1]
$ du -sk vspackage
1244    vspackage
$ md5sum vspackage
10f6bdb1151a954a702f8a6db6f3bd52  vspackage

Windows:

> certutil.exe -hashfile .\llvm-vs-code-extensions.vscode-clangd-0.1.9.vsix MD5
MD5 hash of .\llvm-vs-code-extensions.vscode-clangd-0.1.9.vsix:
74f82f716616796157bde8008c8e5a45
CertUtil: -hashfile command completed successfully.
> Invoke-WebRequest https://marketplace.visualstudio.com/_apis/public/gallery/publishers/llvm-vs-code-extensions/vsextensions/vscode-clangd/latest/vspackage -OutFile vspackage
> Get-ChildItem .\vspackage | % {[int]($_.length / 1kb)}
1383
> certutil.exe -hashfile .\vspackage MD5
MD5 hash of .\vspackage:
74f82f716616796157bde8008c8e5a45
CertUtil: -hashfile command completed successfully.

The hash of the downloaded file is not the same even though the download URL is.

It seems I am missing a few bytes on Linux which would explain the Corrupt ZIP error.

Does somebody understand what I am missing here?


Solution

  • I tried the URL you supplied

    $ wget -nv https://marketplace.visualstudio.com/_apis/public/gallery/publishers/llvm-vs-code-extensions/vsextensions/vscode-clangd/latest/vspackage
    2021-02-11 09:04:22 URL:https://marketplace.visualstudio.com/_apis/public/gallery/publishers/llvm-vs-code-extensions/vsextensions/vscode-clangd/latest/vspackage [1270960/1270960] -> "vspackage"
    

    Let's see what vspackage is

    $ file vspackage
    vspackage: gzip compressed data, max speed, from FAT filesystem (MS-DOS, OS/2, NT), original size modulo 2^32 1416661
    

    That isn't a zip, it is a compressed gzip file. Let's uncompress that

    $ mv vspackage vspackage.gz
    $ gunzip -v vspackage.gz
    vspackage.gz:    10.3% -- replaced with vspackage
    

    What is vspackage now ?

    $ file vspackage
    vspackage: Zip archive data, at least v2.0 to extract
    

    Finally, a zip file.