{"record":{"id":"313dbc143226b339","repo":"caddyserver/caddy","slug":"download-succeeded-but-unable-to-execute-caddy-l","errorCode":null,"errorMessage":"download succeeded, but unable to execute 'caddy list-modules': %v","messagePattern":"download succeeded, but unable to execute 'caddy list-modules': (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/packagesfuncs.go","lineNumber":194,"sourceCode":"\t\t\t\t\tzap.String(\"backup_path\", backupExecPath),\n\t\t\t\t\tzap.String(\"original_path\", thisExecPath),\n\t\t\t\t\tzap.Error(err2))\n\t\t\t}\n\t\t}\n\t}()\n\n\t// download the file; do this in a closure to close reliably before we execute it\n\terr = writeCaddyBinary(thisExecPath, &resp.Body, thisExecStat)\n\tif err != nil {\n\t\treturn caddy.ExitCodeFailedStartup, err\n\t}\n\n\tl.Info(\"download successful; displaying new binary details\", zap.String(\"location\", thisExecPath))\n\n\t// use the new binary to print out version and module info\n\tfmt.Print(\"\\nModule versions:\\n\\n\")\n\tif err = listModules(thisExecPath); err != nil {\n\t\treturn caddy.ExitCodeFailedStartup, fmt.Errorf(\"download succeeded, but unable to execute 'caddy list-modules': %v\", err)\n\t}\n\tfmt.Println(\"\\nVersion:\")\n\tif err = showVersion(thisExecPath); err != nil {\n\t\treturn caddy.ExitCodeFailedStartup, fmt.Errorf(\"download succeeded, but unable to execute 'caddy version': %v\", err)\n\t}\n\tfmt.Println()\n\n\t// clean up the backup file\n\tif !fl.Bool(\"keep-backup\") {\n\t\tif err = removeCaddyBinary(backupExecPath); err != nil {\n\t\t\treturn caddy.ExitCodeFailedStartup, fmt.Errorf(\"download succeeded, but unable to clean up backup binary: %v\", err)\n\t\t}\n\t} else {\n\t\tl.Info(\"skipped cleaning up the backup file\", zap.String(\"backup_path\", backupExecPath))\n\t}\n\n\tl.Info(\"upgrade successful; please restart any running Caddy instances\", zap.String(\"executable\", thisExecPath))\n","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/caddyserver/caddy/blob/50e54ee279aa1e504fe218ca49ab6ae16c100410/cmd/packagesfuncs.go#L176-L212","documentation":"After a successful download and write of the new binary, caddy runs '<newexec> list-modules --versions --skip-standard' via exec.Command to display module info. This error means that subprocess failed to start or exited non-zero. The new binary is already in place; the deferred restore is not triggered because err is reassigned... actually it is: the returned err triggers the deferred restore, so the original binary is restored from the .tmp backup.","triggerScenarios":"The freshly written binary cannot be executed: exec format error (wrong GOARCH/GOOS from the build API), the file lost its exec bit (writeCaddyBinary preserves the original mode, so this is rare), a corrupted/truncated download that still wrote to disk, or antivirus/quarantine blocking execution on Windows/macOS.","commonSituations":"Downloaded build is corrupted by a proxy; the download API returned a build for the wrong platform; macOS Gatekeeper quarantining a newly written binary; disk filled mid-write so the binary is truncated.","solutions":["Check the binary manually: file $(which caddy) and run 'caddy version' to see the raw exec error","Re-run the upgrade — a corrupted download is usually transient","Verify disk space: df -h on the binary's filesystem","If the platform build is wrong, download a standard release binary from GitHub releases instead of the custom build API","On macOS/Windows, exclude the caddy path from Gatekeeper/antivirus quarantine"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# after an upgrade attempt, verify the binary executes before relying on it\ncaddy version && caddy list-modules --versions | head","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep --keep-backup in mind: passing it retains the .tmp rollback copy","Ensure the download API build matches your platform (run upgrade on the target host, not a different arch)","Exclude the caddy path from antivirus quarantine on Windows/macOS"],"tags":["upgrade","exec","subprocess","cli"],"backgroundTag":null,"analyzedSha":"50e54ee279aa1e504fe218ca49ab6ae16c100410","analyzedAt":"2026-08-15T09:20:21.641Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}