Skip to content

[ENG-27] Don't silently fail the examples download when unzip is missing - #311

Merged
zanjonke merged 1 commit into
mainfrom
zan/eng-27-installation-of-examples-should-not-silently-fail-if-unzip
Sep 3, 2026
Merged

[ENG-27] Don't silently fail the examples download when unzip is missing#311
zanjonke merged 1 commit into
mainfrom
zan/eng-27-installation-of-examples-should-not-silently-fail-if-unzip

Conversation

@zanjonke

@zanjonke zanjonke commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Closes ENG-27.

Problem

On an image without unzip (e.g. python:3.12-slim), examples.sh printed Extracting to ... and then died with exit 127 and no message: unzip's stderr went to /dev/null, and set -euo pipefail exited before the if [ $? -eq 0 ] check could run. Because install.sh runs the script as a plain command, the whole installer went down with it, skipping the final verification and summary.

The same unreachable cmd 2>/dev/null; if [ $? ... ] pattern was used for mkdir and curl.

Changes

  • Check for unzip (Expand-Archive on PowerShell) before anything is downloaded, and explain how to install it plus where else to get the examples.
  • Every failure path now requires an acknowledgement (Continue? Press [Enter] to acknowledge:) so the message isn't cleared away by the installer's next step. The "failed to create directory" case previously had no prompt at all.
  • Real if ! cmd checks instead of the $? patterns; a failed extraction shows the extractor's own error (capped at 3 lines) instead of discarding it.
  • A download that isn't a zip (server error page) is reported as such rather than handed to the extractor.
  • The optional examples step can no longer abort the installer — || echo ... in bash, try/catch in install.ps1, where & $scriptPath propagates terminating errors into the parent under $ErrorActionPreference = 'Stop' (verified).
  • Prompts fall back to stdin when there is no controlling terminal, and clear can't abort the script.

Testing

Manually, in Docker with a pty, both with and without the extractor:

  • bash / unzip present → examples extracted, all 8 example .sh scripts still executable
  • bash / unzip absent → guidance + acknowledgement, installer runs to You're all set!, exit 0
  • PowerShell 7.6 / Expand-Archive present → examples extracted
  • PowerShell 7.6 / module removed → guidance + acknowledgement, exit 0

Also checked the failed-download and non-zip-download paths, and full install.sh runs end to end. Note the PowerShell runs were pwsh-on-Linux, so Windows-specific path/permission behaviour is untested.

Slim images ship no unzip. Under `set -euo pipefail` the failing
`unzip ... 2>/dev/null` call aborted examples.sh - and with it the whole
installer, since install.sh runs it as a plain command - without printing
anything.

- Check for unzip (Expand-Archive on PowerShell) before downloading and
  explain how to install it, instead of stopping.
- Make the user acknowledge every failure path, including the previously
  unprompted "failed to create directory" case.
- Replace the `cmd 2>/dev/null; if [ $? ... ]` patterns that `set -e` never
  reached with real checks, and keep the extractor's error output.
- Reject a download that isn't a zip, so a server error page is reported as
  such instead of being handed to the extractor.
- Never let the optional examples step take the installer down (bash: set -e;
  PowerShell: a terminating error propagating out of `& $scriptPath`).
@zanjonke
zanjonke force-pushed the zan/eng-27-installation-of-examples-should-not-silently-fail-if-unzip branch from 8bbdbe3 to 63cf9c6 Compare September 1, 2026 13:09
@zanjonke
zanjonke requested a review from NejcS September 1, 2026 13:10

@NejcS NejcS left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@zanjonke
zanjonke merged commit 37ce1c7 into main Sep 3, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants