Skip to main content
Version: 5.9.x

aspect clean

Remove the output tree


Removes bazel-created output, including all object files, and bazel metadata.


clean deletes the output directories for all build configurations performed by this Bazel instance, or the entire working tree created by this Bazel instance, and resets internal caches.

If executed without any command-line options, then the output directory for all configurations will be cleaned.

Recall that each Bazel instance is associated with a single workspace, thus the clean command will delete all outputs from all builds you've done with that Bazel instance in that workspace.

'clean all': Aspect CLI adds the ability to clean all Bazel workspaces on your machine, by adding the argument "all".

NOTE: clean is primarily intended for reclaiming disk space for workspaces that are no longer needed. It causes all subsequent builds to be non-incremental. If this is not your intent, consider these alternatives:

Do a one-off non-incremental build: bazel --output_base=$(mktemp -d) ...

Force repository rules to re-execute: bazel sync --configure

Workaround inconistent state: Bazel's incremental rebuilds are designed to be correct, so clean should never be required due to inconsistencies in the build. Such problems are fixable and these bugs are a high priority. If you ever find an incorrect incremental build, please file a bug report, and only use clean as a temporary workaround.

aspect clean [--expunge] [all] [flags]


  -h, --help   help for clean

Options inherited from parent commands

      --aspect:config string   User-specified Aspect CLI config file. /dev/null indicates that all further --aspect:config flags will be ignored.
--aspect:interactive Interactive mode (e.g. prompts for user input)