Skip to content
Command lineExit codes and errors

Exit codes and errors

What each census exit code means, every error code it can report, and what to do about each one.

On this page

Exit codes

CodeStatusMeaning
0ok, completeDone. A query succeeded, a scan completed, or a cleanup deleted everything it could. Skipped items are normal.
1failedA bad request: arguments, a selection, a missing confirmation. Nothing was deleted.
2failedAn operational failure: a scan failed, another cleanup was running, the Trash couldn’t be read.
4partialPartly done: some folders couldn’t be read, some items couldn’t be fully deleted, or a maintenance task failed.
7not_foundNo saved result: no scan, no review set, or the path or app isn’t in the scan.
130cancelledCtrl-C or SIGTERM stopped it.
141—stdout closed early (SIGPIPE), as in census top | head -1. Nothing is printed.

With --json, the same number is in the envelope’s exit_code, and errors says why.

Handle errors in a script

Terminal
census clean --safe --json > result.json
case $? in
  0) jq -r '"Freed \(.results.freed_bytes) bytes"' result.json ;;
  4) jq -r '.results.items[] | select(.outcome.result == "failed" or .outcome.result == "partial") | .path.display' result.json ;;
  7) echo "No saved scan. Run: census scan" >&2 ;;
  *) jq -r '.errors[0].message' result.json >&2 ;;
esac

Error codes

Every failure has a code in errors[].code and a message meant for people.

CodeExitWhat happenedWhat to do
invalid_request1A misspelled command or option, a bad value, or an option given twice. For example unknown command: tpo (did you mean top?).Fix the arguments. census help COMMAND lists a command’s options.
ambiguous_app1The app name matches more than one app.Use the app’s bundle ID.
output_exists1export --output names a file that exists.Pick another path, or add --force.
confirmation_required1A command that deletes ran without a terminal and without --safe or --yes.Pass the flag once the person has agreed.
invalid_selection1A path in the selection file, or a PATH argument, isn’t one census listed. Nothing was deleted.Copy paths exactly from review --json, duplicates --json or large --json.
review_stale1The review set, duplicate search or Large Files listing is more than 7 days old.Run census review --json (or the search) again.
run_as_root1A cleanup ran with sudo.Run it as yourself.
cache_unreadable2The saved scan couldn’t be read.Scan again.
busy2In census serve, another long job is running.Wait for it, then send the request again.
scan_failed2The scan couldn’t run.Read the message.
output_failed2export couldn’t write the report.Check the path and its permissions.
selftest_failed2A self-test scenario failed.See selftest.
cleanup_running2Another cleanup is running.Wait for it to finish. Don’t retry in a loop.
cleanup_failed2The cleanup couldn’t run.Read the message.
trash_unreadable2A Trash couldn’t be read, so nothing was deleted.Give the app that runs census Full Disk Access.
partial_scan4Some folders couldn’t be read.See read_errors in the scan’s JSON. Full Disk Access often helps.
partial_cleanup4Some items couldn’t be fully deleted.Check each item’s outcome.
maintenance_failed4A maintenance task failed. The others still ran.Check the task’s result and detail.
no_review7There is no review set, duplicate search or Large Files listing to apply.Run census review --json first.
no_cache7There is no saved scan for the scope.Run census scan.
path_not_scanned7The path isn’t in the saved scan.Scan a scope that includes it.
apps_not_scanned7The scan doesn’t include your apps.Run census scan, the whole drive.
home_not_scanned7The scan doesn’t include your home folder.Run census scan, the whole drive.
app_not_found7No installed app matches the name.Check the name with census apps.
cancelled130The command was stopped.What was deleted so far is in the audit log.

Uninstall errors

census uninstall adds a few codes of its own:

CodeExitWhat happened
app_running1A program inside the app is still running, so nothing was deleted. census never quits apps. Quit it and try again.
needs_admin1The app has a folder you can’t change, or a locked or SIP-protected entry.
system_app1The app is part of macOS.
not_removable1The app can’t be removed.
app_not_removed4The app wasn’t fully deleted, so its data was left as it was. EPERM usually means macOS’s App Management protection: allow the app that runs census in System Settings › Privacy & Security.

Scan read errors

A scan’s read_errors describes paths it couldn’t read. It is scan data, separate from errors. Each recorded path has a code:

CodeMeaningMakes the scan partial
sip_protectedProtected by System Integrity Protection.No
root_onlyOwned by root, and its permissions deny you. sudo can include it.No
other_owner_privateOwned by another user or service account.No
os_protectedmacOS keeps it from every app, even with Full Disk Access.No
full_disk_access_requiredNeeds Full Disk Access, which this process doesn’t have.Yes
access_deniedDenied for another reason, including your own folder without read permission.Yes
path_disappearedRemoved between listing and reading.No

Updated · census JSON schema 5