sdkman / sdkman-cli

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

Bug: `zip` not installed, unclear error message #1304

Open Eonfge opened 4 months ago

Eonfge commented 4 months ago

Bug report When zip is not installed on a Linux system, there is no clear error message when unpacking a .zip file fails.

To reproduce

[kevin@fedora ~]$ sdk install java 21.0.4-amzn

Downloading: java 21.0.4-amzn

In progress...

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

Repackaging Java 21.0.4-amzn...
/usr/bin/env: ‘zip’: No such file or directory

Done repackaging...
unzip:  cannot find or open /home/kevin/.sdkman/tmp/java-21.0.4-amzn.zip, /home/kevin/.sdkman/tmp/java-21.0.4-amzn.zip.zip or /home/kevin/.sdkman/tmp/java-21.0.4-amzn.zip.ZIP.

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

System info

Triage

marc0der commented 4 months ago

@Eonfge We've had issues with command -v in the past because not all systems support it.

For end-users: install SDKMAN via the official installation channel. The installer will halt if you don't have all the necessary dependencies (zip, unzip, curl) installed.

Eonfge commented 3 months ago

Hey, I think there is a small gap in the functionality here: Once installed, there is no check when running SDKMAN.

I must have installed SDKMAN 2 years ago on this laptop, and in the meantime dependencies have changed for other applications. Thus, zip was removed. If SDKMAN were to be distributed with a reliable packaging method like DEB and/or RPM, this problem could have been avoided.

For now, it would be best to just add a runtime check for zip


Could you btw tell me which systems don't support command -v since it's a mandatory part of the POSIX standard which all Shells should support.

marc0der commented 3 months ago

Okay, sorry for my misinformation. I went back and looked at the project history and found that we had introduced command -v elsewhere instead of using which.

If you were up for taking on this work on, your PR would be greatly appreciated. Also, with the Rust rewrite underway, keep in mind that these issues will disappear once we no longer rely on the bash functions.