Billionmail/BillionMail · error
unrar command not found, please install it first
Error message
unrar command not found, please install it first
What it means
UnrarWithExternalCommand extracts rar archives by invoking the external 'unrar' CLI. It first runs exec.LookPath("unrar"); when the binary is missing from PATH it returns this error without attempting extraction. Unlike compression, the underlying Go rar library only reads archives, but this function specifically depends on the external tool being present.
Source
Thrown at core/internal/service/compress/rar.go:232
// Unrar rar decompression
// @author <2024-06-09>
func Unrar(src, dst string) error {
return defaultRarUnpacker.Decompress(src, dst)
}
// Rar compresses files or directories into a rar archive
// @author <2024-06-09>
func Rar(dst string, srcList ...string) error {
return defaultRarUnpacker.Compress(dst, srcList...)
}
// UnrarWithExternalCommand decompresses a rar file using external rar command
// This is an alternative method using the external rar command
func UnrarWithExternalCommand(src, dst string) error {
// check if 'unrar' command exists
_, err := exec.LookPath("unrar")
if err != nil {
return errors.New("unrar command not found, please install it first")
}
// get absolute paths
srcAbs, err := filepath.Abs(src)
if err != nil {
return err
}
dstAbs, err := filepath.Abs(dst)
if err != nil {
return err
}
// ensure destination directory exists
if err := os.MkdirAll(dstAbs, 0755); err != nil {
return err
}
View on GitHub (pinned to fc36c76c05)
Solutions
- Install unrar (apt-get install unrar / apk add unrar / UnRAR for Windows) and verify with `which unrar`
- Add unrar to the deployment Dockerfile
- Use RarUnpacker's built-in Decompress (pure-Go read) instead of the external-command variant
- Pre-check exec.LookPath("unrar") at service startup and fail fast with a clear setup message
Example fix
// before
cmd := exec.Command("unrar", "x", "-o+", src, dst)
// after (Dockerfile)
RUN apt-get update && apt-get install -y --no-install-recommends unrar && rm -rf /var/lib/apt/lists/* Defensive patterns
Strategy: fallback
Validate before calling
if _, err := exec.LookPath("unrar"); err != nil {
return fmt.Errorf("unrar is not installed: %w", err)
} Try / catch
if err := UnrarWithExternalCommand(src, dst); err != nil && strings.Contains(err.Error(), "unrar command not found") {
// fall back to the built-in pure-Go Decompress or install unrar
} Prevention
- Install unrar in every environment that runs extraction (including Docker images)
- Prefer the built-in pure-Go Decompress to drop the external dependency
- Probe exec.LookPath("unrar") at service startup
- Keep PATH configuration consistent between shells, systemd, and containers
When it happens
Trigger: Calling UnrarWithExternalCommand(src, dst) on hosts where unrar is not installed (minimal Docker images, CI runners, Windows without UnRAR.exe on PATH).
Common situations: Alpine/slim images lacking unrar; PATH not including /usr/local/bin in systemd or docker exec contexts; confusing rar (compressor) with unrar (extractor) — installing one does not provide the other.
Related errors
- rar 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/6a3d9c428f780dd4.
Report an issue: GitHub.