Knowledge Base:Portage fails to label files because setfiles does not work anymore

Synopsis
When trying to (re)install software, Portage breaks during the Setting SELinux security labels phase. The below error message is an example:

Environment
This article applies to Gentoo Linux installations with a selinux profile:

Analysis
If for some reason setfiles no longer works, any install activity performed by Portage will fail since it calls setfiles during each installation. Rebuilding thus fails.

Resolution
Rebuild but temporarily disable SELinux support:

Then, run rlpkg to fix the labels of the package: