Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 653230 - app-portage/porthole-0.6.1-r5 with >sys-apps/portage-2.3.24-r1 - KeyError: 'PORTDIR'
Summary: app-portage/porthole-0.6.1-r5 with >sys-apps/portage-2.3.24-r1 - KeyError: 'P...
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core (show other bugs)
Hardware: All Linux
: Normal major (vote)
Assignee: Portage team
Keywords: InVCS
Depends on:
Blocks: 651804
  Show dependency tree
Reported: 2018-04-15 12:40 UTC by Carl W. Harlow
Modified: 2018-06-02 00:07 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Note You need to log in before you can comment on or make changes to this bug.
Description Carl W. Harlow 2018-04-15 12:40:42 UTC
when run from the shell I get the following error message:

Porthole: python version =  2.7.14 (default, Nov 11 2017, 21:49:12) 
[GCC 6.4.0]
importing installed modules
starting main()
CONFIG: id initialized to  325994
CONFIGURATION: id initialized to  326961
PREFERENCES: id initialized to  405708
DEBUG: id initialized to  658775
UTILS: =  658775
PREFERENCES: imported =  658775
BACKENDS: id initialized to  893488
PORTAGELIB: id initialized to  894514
STERMINAL: id initialized to  913597
VERSION_SORT: id initialized to  946272
PROPERTIES: id initialized to  948829
METADATA: id initialized to  949615
PORTAGELIB: imported portage-2.2 modules
PORTAGELIB: portage version = 2.3.28
Traceback (most recent call last):
  File "/usr/lib/python-exec/python2.7/porthole", line 114, in <module>
  File "/usr/lib64/python2.7/site-packages/porthole/", line 165, in main
  File "/usr/lib64/python2.7/site-packages/porthole/backends/", line 36, in load
    from porthole.backends import portagelib
  File "/usr/lib64/python2.7/site-packages/porthole/backends/", line 756, in <module>
    settings = PortageSettings()
  File "/usr/lib64/python2.7/site-packages/porthole/backends/", line 673, in __init__
  File "/usr/lib64/python2.7/site-packages/porthole/backends/", line 703, in reset
    self.portdir = self.settings.environ()['PORTDIR']
KeyError: 'PORTDIR'

I upgraded to portage 2.3.28 and encountered this, tried .27 and .26 as well. Downgrading to the current stable, 2.3.24-r1 resolved the issue
Comment 1 Zac Medico gentoo-dev 2018-04-15 21:06:44 UTC
It's due to this change related to EAPI 7:

We could change the behavior of the eapi_exports_PORTDIR to return true when eapi is None, and then self.settings.environ()['PORTDIR'] would work by default.

However, it's better if porthole uses a different means to get the portdir, for example it could use self.settings.repositories.mainRepoLocation() instead.
Comment 2 Zac Medico gentoo-dev 2018-04-16 01:47:38 UTC
I've posted a patch for review, to revert the change in portage behavior when EAPI is not specified:
Comment 3 Larry the Git Cow gentoo-dev 2018-04-17 02:22:29 UTC
The bug has been referenced in the following commit(s):

commit 3628eaf7d4691c249943e9059ba2ddc60253ba82
Author:     Zac Medico <>
AuthorDate: 2018-04-16 01:33:59 +0000
Commit:     Zac Medico <>
CommitDate: 2018-04-17 02:22:00 +0000

    config.environ(): filter PORTDIR only when required (bug 653230)
    The changes related bug 373349 were more aggressive than necessary,
    causing the PORTDIR variable to be omitted from config.environ()
    calls when the EAPI is defined. We really only need to filter the
    PORTDIR variable when the current EAPI requires it.
    Fixes: 802e7d0bdd96 ("Do not export PORTDIR & ECLASSDIR in EAPI 7")

 pym/portage/ | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)}
Comment 4 Zac Medico gentoo-dev 2018-04-18 16:57:41 UTC
Please test with sys-apps/portage-2.3.30.
Comment 5 Carl W. Harlow 2018-04-21 04:47:58 UTC
sys-apps/portage-2.3.31 works for me, thanks
Comment 6 Zac Medico gentoo-dev 2018-06-02 00:07:41 UTC
(In reply to Carl W. Harlow from comment #5)
> sys-apps/portage-2.3.31 works for me, thanks

Great, thanks for testing!