Billionmail/BillionMail · error

rar compression failed: %s - %s

Error message

rar compression failed: %s - %s

What it means

Compress runs `rar <args>` via exec.Command and captures combined stdout/stderr. If the rar process exits non-zero, this error wraps the exec error and the raw CLI output, indicating the rar tool itself failed (bad options, license prompt, unreadable source, password-protected archive, etc.).

Source

Thrown at core/internal/service/compress/rar.go:203

			return err
		}

		// make sure source exists
		if _, err := os.Stat(srcAbs); err != nil {
			return fmt.Errorf("source file/directory does not exist: %s", src)
		}

		// add source to arguments
		args = append(args, srcAbs)
	}

	// create command
	cmd := exec.Command("rar", args...)

	// run command
	output, err := cmd.CombinedOutput()
	if err != nil {
		return fmt.Errorf("rar compression failed: %s - %s", err, string(output))
	}

	// verify the file was created
	if _, err := os.Stat(dstAbs); err != nil {
		return errors.New("rar file was not created successfully")
	}

	return nil
}

// 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>

View on GitHub (pinned to fc36c76c05)

Solutions

  1. Read the embedded output in the error message to identify the rar CLI failure reason
  2. Ensure the process user can read sources and write the destination directory
  3. Handle the rar evaluation license (purchase/register or use `rar a -y` with a valid license file rarreg.key)
  4. Check free disk space on the destination volume
  5. Consider using the pure-Go gzip unpacker or `zip` CLI to avoid the proprietary rar dependency

Example fix

// before
cmd := exec.Command("rar", args...)
// after
cmd := exec.Command("rar", args...)
cmd.Stdin = nil // avoid hanging on license prompt; check output in returned error and fix cause
Defensive patterns

Strategy: try-catch

Validate before calling

if _, err := exec.LookPath("rar"); err != nil { return err }
for _, src := range srcList {
	if _, err := os.Stat(src); err != nil { return err }
}
if err := os.MkdirAll(filepath.Dir(dst), 0755); err != nil { return err }

Try / catch

if err := r.Compress(dst, src...); err != nil {
	if strings.HasPrefix(err.Error(), "rar compression failed:") {
		log.Printf("rar CLI failed: %v", err) // output is embedded after the dash
	}
}

Prevention

When it happens

Trigger: rar exits non-zero during RarUnpacker.Compress: invalid args, rar trial-license interactive prompt on stdin absence, permission-denied on source/output, disk full, or corrupt/locked sources.

Common situations: rar CLI on a headless server hitting the evaluation-license prompt; output directory not writable by the service user; volumes mounted read-only; password-protected inputs.

Related errors


AI-assisted analysis of Billionmail/BillionMail@fc36c76c05 (2026-09-05). Data as JSON: /api/errors/1921d18d36b192fa. Report an issue: GitHub.