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

Bug 653230

Summary: app-portage/porthole-0.6.1-r5 with >sys-apps/portage-2.3.24-r1 - KeyError: 'PORTDIR'
Product: Portage Development Reporter: Carl W. Harlow <harlowcw>
Component: CoreAssignee: Portage team <dev-portage>
Status: RESOLVED FIXED    
Severity: major CC: dolsen, jstein, tools-portage
Priority: Normal Keywords: InVCS
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 651804    

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
initializing utils.__init__.py
DEBUG: id initialized to  658775
UTILS: mydebug.id =  658775
PREFERENCES: imported debug.id =  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>
    main()
  File "/usr/lib64/python2.7/site-packages/porthole/startup.py", line 165, in main
    backends.load(BACKEND) 
  File "/usr/lib64/python2.7/site-packages/porthole/backends/__init__.py", line 36, in load
    from porthole.backends import portagelib
  File "/usr/lib64/python2.7/site-packages/porthole/backends/portagelib.py", line 756, in <module>
    settings = PortageSettings()
  File "/usr/lib64/python2.7/site-packages/porthole/backends/portagelib.py", line 673, in __init__
    self.reset()
  File "/usr/lib64/python2.7/site-packages/porthole/backends/portagelib.py", 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:

https://gitweb.gentoo.org/proj/portage.git/commit/?id=802e7d0bdd967d28c6dbb31fd84e8dfd540d794a

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:

https://archives.gentoo.org/gentoo-portage-dev/message/ea185a43cdc4c4b87297bcea01fbad54
https://github.com/gentoo/portage/pull/303
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):

https://gitweb.gentoo.org/proj/portage.git/commit/?id=3628eaf7d4691c249943e9059ba2ddc60253ba82

commit 3628eaf7d4691c249943e9059ba2ddc60253ba82
Author:     Zac Medico <zmedico@gentoo.org>
AuthorDate: 2018-04-16 01:33:59 +0000
Commit:     Zac Medico <zmedico@gentoo.org>
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")
    Bug: https://bugs.gentoo.org/653230

 pym/portage/eapi.py | 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!