Billionmail/BillionMail · error
rar command not found, please install it first
Error message
rar command not found, please install it first
What it means
RarUnpacker.Compress shells out to the proprietary 'rar' CLI rather than implementing rar compression in Go. Before running, it calls exec.LookPath("rar"); if the binary is not on PATH it returns this error. The rar CLI is not free software and is often absent from containers and CI images.
Source
Thrown at core/internal/service/compress/rar.go:161
// increase the size of already decompressed file
return r.incWritten(n)
}()
if err != nil {
return err
}
}
return nil
}
// Compress compresses files or directories into a rar archive using external rar command
func (r *RarUnpacker) Compress(dst string, srcList ...string) error {
// check if 'rar' command exists
_, err := exec.LookPath("rar")
if err != nil {
return errors.New("rar command not found, please install it first")
}
// ensure dst ends with .rar
if !strings.HasSuffix(strings.ToLower(dst), ".rar") {
dst += ".rar"
}
// get absolute paths to avoid path traversal issues
dstAbs, err := filepath.Abs(dst)
if err != nil {
return err
}
// prepare command arguments
args := []string{"a", "-ep1", "-r"}
// add destination file
args = append(args, dstAbs)View on GitHub (pinned to fc36c76c05)
Solutions
- Install the rar binary (e.g. apt-get install rar or download from rarlab.com) and ensure it is on PATH
- Add rar to the Dockerfile of the deployment image
- Switch to the gzip/zip unpacker if rar format is not strictly required
- Verify with `which rar` inside the same user/container context that runs the service
Example fix
// Dockerfile before FROM alpine // after FROM alpine RUN apk add --no-cache unrar && wget -O /usr/local/bin/rar https://www.rarlab.com/rar/rarlinux-x64-*.tar.gz (or apt-get install rar)
Defensive patterns
Strategy: fallback
Validate before calling
if _, err := exec.LookPath("rar"); err != nil {
return fmt.Errorf("rar is not installed: %w", err)
} Try / catch
if err := r.Compress(dst, src...); err != nil && strings.Contains(err.Error(), "rar command not found") {
// fall back to gzip unpacker or surface install instructions to the operator
} Prevention
- Install rar explicitly in the deployment image/Dockerfile
- Check exec.LookPath("rar") at startup with a clear boot error
- Standardize on gzip/zip if rar is not a hard requirement
- Document the rar dependency for CI and production environments
When it happens
Trigger: Calling RarUnpacker.Compress on a machine where the rar executable is not installed or not on PATH (common in slim Docker images, Alpine, CI runners).
Common situations: Deploying to a minimal container that only has unzip/gzip; switching environments where rar was installed manually; PATH differences between dev shell and systemd/docker context.
Related errors
- unrar command not found, please install it first
- disk quota exceeded
- illegal file path:
- source file/directory does not exist: %s
- rar compression failed: %s - %s
AI-assisted analysis of Billionmail/BillionMail@fc36c76c05 (2026-09-05).
Data as JSON: /api/errors/376f6532f73b4632.
Report an issue: GitHub.