How should the sstate-cache directory be deleted in Yocto?

The correct task for this is:

$ bitbake -c cleansstate <recipe-name>

See: Yocto Reference Manual

There are more tasks for cleaning, which remove sstate cache and even more (e.g. do_cleanall).


According to the Yocto Reference Manual it is safe to remove the complete build/tmp directory including the sstate-cache directory:

As a last resort, to clean up a build and start it from scratch (other than the downloads), you can remove everything in the tmp directory or get rid of the directory completely. If you do, you should also completely remove the build/sstate-cache directory. (see [1] and [2])

Furthermore you can remove the sstate-cache with bitbake for a specific recipe by calling do_cleansstate like shown below (see do_cleansstate).

$ bitbake -c cleansstate recipe

Please be aware that the Shared State Cache needs a lot of memory and it will be growing again to the size it needs to build your images.

More detailed information on the Shared State Cache is available in following sections of the Yocto Reference Manual: Shared State Cache and sstate-cache.

Tags:

Bitbake

Yocto