You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 9, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Nov 9, 2026. It is now read-only.
msk(1) package install continues on failed download #354
If my msk.conf points to the wrong thing, or if the package mirror is not configured properly, the download might get a http 404 error. In this case, a package has not been fetched. msk(1) should not proceed with any install steps. I think it is more correct to just show an error: "Unable to fetch package from $ATTEMPTED_URL" and exit.
# msk install doom
Download doom...
Bad response code: 404
Install 'doom'...
gunzip: unspecified error from inflate
failed to read file
/usr/share/games/doom/install_desktop_launcher.sh: Command not found
post-installation command returned 127
msk actually does try to check for failure at each step and bail, but:
fetch doesn't actually return an error code on 404, so we continue to the next step. On its own, this would be expected behavior - we would need a flag to have a 404 return an error code: curl has --fail, for example.
fetch still creates the destination file, so tar opens an empty file, which it doesn't care about initially, and passes to gunzip.
gunzip correctly fails and returns an error code, but tar never sees this: it does not wait on gunzip at all (which ends up orphaned and is cleaned up by init when tar itself finishes).
tar's extract_file fails to read a header with fopen, prints an error message, and ends extracting, but does not return an error code, so we continue to the next step.
rm is happy to remove the empty temp file, and we continue to the next step.
msk sees the failure of the post-install script not existing and finally bails.
Fixing the first issue in fetch is a little annoying as we have a second version of it in the repository that uses mbedtls to support SSL/TLS connections. I would really like to re-implement that in a way where the original fetch is still the frontend and the mbedtls integration comes from an optional library that is dlopened, similar to how JPEG and PNG support is optional in libtoaru_graphics or how we used to support a Cairo backend in the compositor.
Having fetch exit with a failure code would be ideal. Even if it optionally supported fetch -o outputfile similar to wget & curl, and fetch is careful not to open() the file on 404, that is still more correct than creating an empty file even if the network is completely down (or the webserver is alive but the URL is wrong).
At least curl is correct in this case and won't create a file, e.g. if the hostname fails to resolve.
The main problem is that fetch is in need of many improvements and should be significantly refactored, so implementing a quick fix here is not worthwhile until those other improvements can be made.
Activity
klange commentedon Feb 12, 2026
mskactually does try to check for failure at each step and bail, but:fetchdoesn't actually return an error code on 404, so we continue to the next step. On its own, this would be expected behavior - we would need a flag to have a 404 return an error code: curl has--fail, for example.fetchstill creates the destination file, sotaropens an empty file, which it doesn't care about initially, and passes togunzip.gunzipcorrectly fails and returns an error code, buttarnever sees this: it does notwaitongunzipat all (which ends up orphaned and is cleaned up byinitwhentaritself finishes).tar'sextract_filefails to read a header withfopen, prints an error message, and ends extracting, but does not return an error code, so we continue to the next step.rmis happy to remove the empty temp file, and we continue to the next step.msksees the failure of the post-install script not existing and finally bails.klange commentedon Feb 12, 2026
Fixing the first issue in
fetchis a little annoying as we have a second version of it in the repository that usesmbedtlsto support SSL/TLS connections. I would really like to re-implement that in a way where the originalfetchis still the frontend and thembedtlsintegration comes from an optional library that isdlopened, similar to how JPEG and PNG support is optional in libtoaru_graphics or how we used to support a Cairo backend in the compositor.mknos commentedon Feb 12, 2026
Having
fetchexit with a failure code would be ideal. Even if it optionally supportedfetch -o outputfilesimilar to wget & curl, andfetchis careful not to open() the file on 404, that is still more correct than creating an empty file even if the network is completely down (or the webserver is alive but the URL is wrong).At least curl is correct in this case and won't create a file, e.g. if the hostname fails to resolve.
klange commentedon Feb 12, 2026
fetchhas an-oargument, andmskuses it here.The main problem is that
fetchis in need of many improvements and should be significantly refactored, so implementing a quick fix here is not worthwhile until those other improvements can be made.klange commentedon Feb 12, 2026
mskitself really needs to be rewritten, but that's a different matter - and already has a very old ticket in #214.