Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 667662

Summary: sys-apps/portage: (ROOT)PATH reconstruction inconsistent with modern baselayout behavior
Product: Portage Development Reporter: Michał Górny <mgorny>
Component: Core - Ebuild SupportAssignee: Portage team <dev-portage>
Severity: normal Keywords: InVCS
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 666956    

Description Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2018-10-03 17:51:18 UTC
$ grep ROOTPATH= /etc/env.d/*

With modern baselayout, this means that root's environment will have PATH constructed from all those, in order.  Most notably, all LLVM directories will be before standard system bindirs.

However, Portage seems to additionally prepend those standard paths before env.d, creating path such as e.g.:

Comment 1 Zac Medico gentoo-dev 2018-10-03 18:03:07 UTC
Some de-duplication logic might do the trick.
Comment 2 Zac Medico gentoo-dev 2018-10-03 18:17:45 UTC
Maybe something like this:

> diff --git a/lib/portage/package/ebuild/ b/lib/portage/package/ebuild/
> index 941a597e2..f27ed897f 100644
> --- a/lib/portage/package/ebuild/
> +++ b/lib/portage/package/ebuild/
> @@ -214,2 +214,3 @@ def _doebuild_path(settings, eapi=None):
>         rootpath = [x for x in settings.get("ROOTPATH", "").split(":") if x]
> +       rootpath_set = frozenset(rootpath)
>         overrides = [x for x in settings.get(
> @@ -245,3 +246,5 @@ def _doebuild_path(settings, eapi=None):
>                 for x in ("usr/local/sbin", "usr/local/bin", "usr/sbin", "usr/bin", "sbin", "bin"):
> -                       path.append(os.path.join(prefix, x))
> +                       x_abs = os.path.join(prefix, x)
> +                       if x_abs not in rootpath_set:
> +                               path.append(x_abs)
Comment 3 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2018-10-03 18:21:54 UTC
Looks good at a first glance.
Comment 5 Larry the Git Cow gentoo-dev 2018-10-08 21:40:59 UTC
The bug has been referenced in the following commit(s):

commit 01b8e9277b3f6970ea09135def26b70dbf072a16
Author:     Zac Medico <>
AuthorDate: 2018-10-08 02:37:59 +0000
Commit:     Zac Medico <>
CommitDate: 2018-10-08 04:29:34 +0000

    _doebuild_path: Respect order defined in ROOTPATH (bug 667662)
    Respect the order of paths defined in /etc/env.d/*, so that
    packages like llvm can rely on ordering relative to paths
    defined in /etc/env.d/50baselayout since baselayout-2.6.
    Signed-off-by: Zac Medico <>

 lib/portage/package/ebuild/ | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)