sdkman / sdkman-cli

The SDKMAN! Command Line Interface
https://sdkman.io
Apache License 2.0
6.05k stars 627 forks source link

Misleading zip error message for broken links #518

Open jbuhacoff opened 7 years ago

jbuhacoff commented 7 years ago

I tried sdk install ant and got this output:

Downloading: ant 1.9.7

In progress...

######################################################################## 100.0%
  End-of-central-directory signature not found.  Either this file is not
  a zipfile, or it constitutes one disk of a multi-part archive.  In the
  latter case the central directory and zipfile comment will be found on
  the last disk(s) of this archive.
unzip:  cannot find zipfile directory in one of /home/Jonathan/.sdkman/archives/ant-1.9.7.zip or
        /home/Jonathan/.sdkman/archives/ant-1.9.7.zip.zip, and cannot find /home/Jonathan/.sdkman/archives/ant-1.9.7.zip.ZIP, period.

Stop! The archive was corrupt and has been removed! Please try installing again.

I looked up this message and found a number of old tickets about wrong version of zip. I'm using cygwin and I checked that I do have the zip and unzip packages from the archive category. I edited the sdkman-install.sh script to skip deleting the "corrupted" zip file and I found that what actually got downloaded was this:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /apache/ant/binaries/apache-ant-1.9.7-bin.zip was not found on this server.</p>
<hr>
<address>Apache/2.4.10 (Debian) Server at mirror.vorboss.net Port 80</address>
</body></html>

I checked the download URL with curl and got this output:

$ curl -L -I https://api.sdkman.io/2/broker/download/ant/1.9.7/cygwin_nt-10.0
HTTP/1.1 302 Found
Server: nginx/1.11.5
Date: Sat, 07 Jan 2017 04:02:12 GMT
Content-Length: 0
Connection: keep-alive
location: http://mirror.vorboss.net/apache/ant/binaries/apache-ant-1.9.7-bin.zip

HTTP/1.1 404 Not Found
Date: Sat, 07 Jan 2017 04:02:13 GMT
Server: Apache/2.4.10 (Debian)
Content-Type: text/html; charset=iso-8859-1

So it appears the root cause of my issue is that the broker is redirecting to a URL that doesn't have the requested package, and the zip error is shown because what got downloaded from the server is some HTML instead of a zip file.

I made a couple of changes in sdkman-util.sh and sdkman-install.sh to detect the HTTP error and produce a more accurate message.

jbuhacoff commented 7 years ago

Please see my pull request #519 for the changes.

Now I get output like this, which accurately describes what happened:

$ sdk install ant

Downloading: ant 1.9.7

In progress...

######################################################################## 100.0%

Failed to download ant from https://api.sdkman.io/2/broker/download/ant/1.9.7/cygwin_nt-10.0
marc0der commented 7 years ago

Thanks for reporting this. Comments left in PR.

ghost commented 7 years ago

Hi, my issue seems related. On a fresh install of minimal ubuntu server 16.04 sdk install properly , sdk java install works, but when i did sdk install grails i got this.

machi@groovyMachi:~$ sdk install grails

Downloading: grails 3.2.11

In progress...

############ 17.5% curl: (56) GnuTLS recv error (-54): Error in the pull function. End-of-central-directory signature not found. Either this file is not a zipfile, or it constitutes one disk of a multi-part archive. In the latter case the central directory and zipfile comment will be found on the last disk(s) of this archive. unzip: cannot find zipfile directory in one of /home/machi/.sdkman/archives/grails-3.2.11.zip or /home/machi/.sdkman/archives/grails-3.2.11.zip.zip, and cannot find /home/machi/.sdkman/archives/grails-3.2.11.zip.ZIP, period.

Stop! The archive was corrupt and has been removed! Please try installing again. machi@groovyMachi:~$

Any workarounds? the whole sdk install grail is broken to me, it constantly timesout even i changes timers to be over 250 sec each

natnael-bedru commented 6 months ago

same issue here installing jetbrains java through sdkman when installing sdkman on gitbash i created a symbolic link named "zip.exe"my to 7zip using powershell (as admin privilege)

New-Item -ItemType SymbolicLink -Path "C:\Program Files\Git\mingw64\bin\zip.exe" -Target "C:\Program Files\7-Zip\7z.exe"

issue