{"record":{"id":"376f6532f73b4632","repo":"Billionmail/BillionMail","slug":"rar-command-not-found-please-install-it-first","errorCode":null,"errorMessage":"rar command not found, please install it first","messagePattern":"rar command not found, please install it first","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/internal/service/compress/rar.go","lineNumber":161,"sourceCode":"\n\t\t\t// increase the size of already decompressed file\n\t\t\treturn r.incWritten(n)\n\t\t}()\n\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}\n\n// Compress compresses files or directories into a rar archive using external rar command\nfunc (r *RarUnpacker) Compress(dst string, srcList ...string) error {\n\t// check if 'rar' command exists\n\t_, err := exec.LookPath(\"rar\")\n\tif err != nil {\n\t\treturn errors.New(\"rar command not found, please install it first\")\n\t}\n\n\t// ensure dst ends with .rar\n\tif !strings.HasSuffix(strings.ToLower(dst), \".rar\") {\n\t\tdst += \".rar\"\n\t}\n\n\t// get absolute paths to avoid path traversal issues\n\tdstAbs, err := filepath.Abs(dst)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// prepare command arguments\n\targs := []string{\"a\", \"-ep1\", \"-r\"}\n\n\t// add destination file\n\targs = append(args, dstAbs)","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/Billionmail/BillionMail/blob/fc36c76c050c3775c5e899faf7403cf0262d2744/core/internal/service/compress/rar.go#L143-L179","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"// Dockerfile before\nFROM alpine\n// after\nFROM alpine\nRUN 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)","handlingStrategy":"fallback","validationCode":"if _, err := exec.LookPath(\"rar\"); err != nil {\n\treturn fmt.Errorf(\"rar is not installed: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := r.Compress(dst, src...); err != nil && strings.Contains(err.Error(), \"rar command not found\") {\n\t// fall back to gzip unpacker or surface install instructions to the operator\n}","preventionTips":["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"],"tags":["go","compression","rar","missing-binary","environment"],"backgroundTag":"missing-external-command","analyzedSha":"fc36c76c050c3775c5e899faf7403cf0262d2744","analyzedAt":"2026-09-05T21:28:54.019Z","contentChangedAt":"2026-09-05T21:28:54.019Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}