As per PMS [0], some variables are only defined during certain phases. e.g. EROOT is only defined within pkg_* and should not be used in e.g. src_*. pkgcheck now implements MisplacedVariable [1] to help detect such cases (experimental). Please be aware that using undefined variables in this way: 1) violates PMS (and the disadvantages that brings); 2) may result in undefined behaviour, including your ebuild not functioning at some later point in time with e.g. a new version of Portage; 3) may not behave as expected in pathological cases like cross-compilation, Gentoo Prefix, binpkgs, or --root. Ask for help if you're not sure of the best way to fix an issue in your package. There are two helpful PMS tables [2] [3] which define which dependency classes are satisfied in which phase and which elements in our CHOST/CBUILD model. This is useful for figuring out if you want e.g. BROOT, ESYSROOT, or just EPREFIX. [0] https://dev.gentoo.org/~ulm/pms/head/pms.html#x1-10900011.1 [1] https://github.com/pkgcore/pkgcheck/commit/552506b076c2cf34fc863df51086f92e7f752393 [2] https://dev.gentoo.org/~ulm/pms/head/pms.html#x1-720008.1 [3] https://dev.gentoo.org/~ulm/pms/head/pms.html#x1-72002r2
*** Bug 608664 has been marked as a duplicate of this bug. ***
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/proj/devmanual.git/commit/?id=fd90736ea1141e95c63a9634d424aa843454ca45 commit fd90736ea1141e95c63a9634d424aa843454ca45 Author: Sam James <sam@gentoo.org> AuthorDate: 2021-03-21 02:31:00 +0000 Commit: Ulrich Müller <ulm@gentoo.org> CommitDate: 2021-03-30 18:14:52 +0000 ebuild-writing/common-mistakes: give more information on invalid ${ROOT} usage Bug: https://bugs.gentoo.org/775191 Signed-off-by: Sam James <sam@gentoo.org> [Add bug number to link text.] Signed-off-by: Ulrich Müller <ulm@gentoo.org> ebuild-writing/common-mistakes/text.xml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
I've now automatically filed bugs for all packages hitting pkgcheck's VariableScope warning, given we need the tree to be clean before we can change Portage's behaviour. Reach out to us in e.g. #gentoo-dev-help, #gentoo-qa if you need help adapting your ebuild.
See also: https://projects.gentoo.org/qa/policy-guide/ebuild-format.html#pg0107 for D and ED.