Skip to content
Latchkey

unrar x: Extract RAR Archives in CI

unrar extracts .rar archives, preserving paths with x and flattening with e; the matching rar tool creates them.

RAR is a proprietary format, so you extract with unrar (free) and create only with rar (nonfree). In CI, unrar x -y handles vendor-supplied .rar drops non-interactively.

What it does

unrar x extracts a .rar archive with full paths; unrar e extracts all files into the current directory; unrar l lists contents; unrar t tests integrity. Passwords are supplied with -p. Creating .rar requires the separate rar binary; unrar is extract-only.

Common usage

Terminal
unrar x vendor.rar ./out/           # extract with paths
unrar e assets.rar                  # flatten into current dir
unrar l archive.rar                 # list contents
unrar x -p"$PASS" locked.rar        # password-protected
# create requires the nonfree rar tool
rar a -m5 out.rar ./dir             # -m5 = max compression

Options

Flag / verbWhat it does
xExtract with full paths
eExtract flat, ignoring stored paths
lList archive contents
tTest the archive
-p<password>Password for an encrypted archive
-o+ / -o-Overwrite existing files / skip existing
-m5 (rar)Maximum compression when creating with rar

In CI

Install with apt-get install -y unrar (or unrar-free, which is more limited). Use -o+ to overwrite existing files without prompting. Since only rar can create archives and it is proprietary, prefer 7z or tar for artifacts you control; reach for unrar only to read .rar you were handed.

Common errors in CI

"unrar: command not found" means the unrar package is missing; apt-get install -y unrar. "Cannot open <file>: No such file or directory" is a bad path. "The specified password is incorrect" means -p is wrong. unrar-free may fail on newer RAR5 archives with a corrupt/format error; install the official unrar instead.

Related guides

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