Skip to content
Latchkey

zip: Usage, Options & Common CI Errors

zip creates cross-platform .zip archives that any OS can open.

zip is preferred when an artifact must be opened on Windows or uploaded to a service that expects .zip (Lambda, many release pages). It is often missing from minimal Linux images.

What it does

zip compresses files and directories into a single .zip archive using the widely supported ZIP format. Unlike tar+gzip, it both bundles and compresses in one tool and is natively readable on Windows.

Common usage

Terminal
zip -r out.zip ./dir            # recurse into directories
zip out.zip a.txt b.txt
zip -j out.zip path/to/*.txt    # junk paths (flat archive)
zip -r -q out.zip ./dir         # quiet
zip -r out.zip . -x '*.git*'    # exclude a pattern

Options

FlagWhat it does
-rRecurse into directories
-j / --junk-pathsStore just file names, no directory paths
-q / --quietSuppress output
-x <pattern>Exclude matching files
-9Maximum compression

Common errors in CI

zip: command not found - Debian/Alpine slim images omit zip; install zip unzip first. Forgetting -r on a directory produces an archive that "zip warning: name not matched" skips, leaving an empty or partial archive. "Nothing to do!" means the patterns matched no files. For AWS Lambda, -r from the right working dir matters: the handler must be at the archive root, not nested.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →