Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 586214 - sys-apps/portage: empty profile triggers KeyError: u'ARCH' in pym/portage/package/ebuild/config.py", line 2629, in _getitem
Summary: sys-apps/portage: empty profile triggers KeyError: u'ARCH' in pym/portage/pac...
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords: InVCS
: 640676 (view as bug list)
Depends on:
Blocks: 637452
  Show dependency tree
 
Reported: 2016-06-17 16:32 UTC by Martin Mokrejš
Modified: 2018-02-01 23:58 UTC (History)
3 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Mokrejš 2016-06-17 16:32:41 UTC
Maybe this is a dupe of bug #575070 ?

I follow https://wiki.gentoo.org/wiki/Project:Prefix/Bootstrap and ./bootstrap-prefix.sh gave me:


...

!!! /scratch/mmokrejs/gentoo/tmp/etc/portage/make.profile is not a symlink and will probably prevent most merges.
!!! It should point into a profile within /scratch/mmokrejs/gentoo/usr/portage/profiles/
!!! (You can safely ignore this message when syncing. It's harmless.)


!!! Problem with sandbox binary. Disabling...


These are the packages that would be merged, in order:

================================================================================================
======== Traceback for invalid call to portage.package.ebuild.config.config.__getitem__ ========
  File "/scratch/mmokrejs/gentoo/tmp/usr/bin/emerge", line 50, in <module>
    retval = emerge_main()
  File "/scratch/mmokrejs/gentoo/tmp/usr/lib/portage/pym/_emerge/main.py", line 1185, in emerge_main
    return run_action(emerge_config)
  File "/scratch/mmokrejs/gentoo/tmp/usr/lib/portage/pym/_emerge/actions.py", line 3273, in run_action
    emerge_config.args, spinner)
  File "/scratch/mmokrejs/gentoo/tmp/usr/lib/portage/pym/_emerge/actions.py", line 325, in action_build
    settings, trees, myopts, myparams, myaction, myfiles, spinner)
  File "/scratch/mmokrejs/gentoo/tmp/usr/lib/portage/pym/_emerge/depgraph.py", line 9196, in backtrack_depgraph
    myaction, myfiles, spinner)
  File "/scratch/mmokrejs/gentoo/tmp/usr/lib/portage/pym/_emerge/depgraph.py", line 9233, in _backtrack_depgraph
    success, favorites = mydepgraph.select_files(myfiles)
  File "/scratch/mmokrejs/gentoo/tmp/usr/lib/portage/pym/_emerge/depgraph.py", line 3583, in select_files
    return self._select_files(args)
  File "/scratch/mmokrejs/gentoo/tmp/usr/lib/portage/pym/_emerge/depgraph.py", line 3926, in _select_files
    return self._resolve(myfavorites)
  File "/scratch/mmokrejs/gentoo/tmp/usr/lib/portage/pym/_emerge/depgraph.py", line 3990, in _resolve
    myroot, atom, onlydeps=onlydeps)
  File "/scratch/mmokrejs/gentoo/tmp/usr/lib/portage/pym/_emerge/depgraph.py", line 5324, in _select_pkg_highest_available
    ret = self._select_pkg_highest_available_imp(root, atom, onlydeps=onlydeps, parent=parent)
  File "/scratch/mmokrejs/gentoo/tmp/usr/lib/portage/pym/_emerge/depgraph.py", line 5558, in _select_pkg_highest_available_imp
    autounmask_level=autounmask_level, parent=parent)
  File "/scratch/mmokrejs/gentoo/tmp/usr/lib/portage/pym/_emerge/depgraph.py", line 5899, in _wrapped_select_pkg_highest_available_imp
    if not self._pkg_visibility_check(pkg, autounmask_level):
  File "/scratch/mmokrejs/gentoo/tmp/usr/lib/portage/pym/_emerge/depgraph.py", line 5596, in _pkg_visibility_check
    mreasons = _get_masking_status(pkg, pkgsettings, root_config, use=self._pkg_use_enabled(pkg))
  File "/scratch/mmokrejs/gentoo/tmp/usr/lib/portage/pym/_emerge/depgraph.py", line 9479, in _get_masking_status
    portdb=root_config.trees["porttree"].dbapi, myrepo=myrepo)
  File "/scratch/mmokrejs/gentoo/tmp/usr/lib/portage/pym/portage/package/ebuild/getmaskingstatus.py", line 100, in _getmaskingstatus
    myarch = settings["ARCH"]
  File "/scratch/mmokrejs/gentoo/tmp/usr/lib/portage/pym/portage/package/ebuild/config.py", line 2576, in __getitem__
    return self._getitem(key)
  File "/scratch/mmokrejs/gentoo/tmp/usr/lib/portage/pym/portage/package/ebuild/config.py", line 2629, in _getitem
    raise KeyError(mykey)
KeyError: u'ARCH'
================================================================================================


!!! Problem in 'sys-libs/ncurses' dependencies.
!!! u'ARCH' None
Traceback (most recent call last):
  File "/scratch/mmokrejs/gentoo/tmp/usr/bin/emerge", line 50, in <module>
    retval = emerge_main()
  File "/scratch/mmokrejs/gentoo/tmp/usr/lib/portage/pym/_emerge/main.py", line 1185, in emerge_main
    return run_action(emerge_config)
  File "/scratch/mmokrejs/gentoo/tmp/usr/lib/portage/pym/_emerge/actions.py", line 3273, in run_action
    emerge_config.args, spinner)
  File "/scratch/mmokrejs/gentoo/tmp/usr/lib/portage/pym/_emerge/actions.py", line 325, in action_build
    settings, trees, myopts, myparams, myaction, myfiles, spinner)
  File "/scratch/mmokrejs/gentoo/tmp/usr/lib/portage/pym/_emerge/depgraph.py", line 9196, in backtrack_depgraph
    myaction, myfiles, spinner)
  File "/scratch/mmokrejs/gentoo/tmp/usr/lib/portage/pym/_emerge/depgraph.py", line 9233, in _backtrack_depgraph
    success, favorites = mydepgraph.select_files(myfiles)
  File "/scratch/mmokrejs/gentoo/tmp/usr/lib/portage/pym/_emerge/depgraph.py", line 3583, in select_files
    return self._select_files(args)
  File "/scratch/mmokrejs/gentoo/tmp/usr/lib/portage/pym/_emerge/depgraph.py", line 3926, in _select_files
    return self._resolve(myfavorites)
  File "/scratch/mmokrejs/gentoo/tmp/usr/lib/portage/pym/_emerge/depgraph.py", line 3990, in _resolve
    myroot, atom, onlydeps=onlydeps)
  File "/scratch/mmokrejs/gentoo/tmp/usr/lib/portage/pym/_emerge/depgraph.py", line 5324, in _select_pkg_highest_available
    ret = self._select_pkg_highest_available_imp(root, atom, onlydeps=onlydeps, parent=parent)
  File "/scratch/mmokrejs/gentoo/tmp/usr/lib/portage/pym/_emerge/depgraph.py", line 5558, in _select_pkg_highest_available_imp
    autounmask_level=autounmask_level, parent=parent)
  File "/scratch/mmokrejs/gentoo/tmp/usr/lib/portage/pym/_emerge/depgraph.py", line 5899, in _wrapped_select_pkg_highest_available_imp
    if not self._pkg_visibility_check(pkg, autounmask_level):
  File "/scratch/mmokrejs/gentoo/tmp/usr/lib/portage/pym/_emerge/depgraph.py", line 5596, in _pkg_visibility_check
    mreasons = _get_masking_status(pkg, pkgsettings, root_config, use=self._pkg_use_enabled(pkg))
  File "/scratch/mmokrejs/gentoo/tmp/usr/lib/portage/pym/_emerge/depgraph.py", line 9479, in _get_masking_status
    portdb=root_config.trees["porttree"].dbapi, myrepo=myrepo)
  File "/scratch/mmokrejs/gentoo/tmp/usr/lib/portage/pym/portage/package/ebuild/getmaskingstatus.py", line 100, in _getmaskingstatus
    myarch = settings["ARCH"]
  File "/scratch/mmokrejs/gentoo/tmp/usr/lib/portage/pym/portage/package/ebuild/config.py", line 2576, in __getitem__
    return self._getitem(key)
  File "/scratch/mmokrejs/gentoo/tmp/usr/lib/portage/pym/portage/package/ebuild/config.py", line 2629, in _getitem
    raise KeyError(mykey)
KeyError: u'ARCH'

Odd!  Running
  /bin/bash ./bootstrap-prefix.sh "/scratch/mmokrejs/gentoo" stage2
failed! :(  Details might be found in the build log:
  (no build logs found?!?)
I have no clue, really.  Please find friendly folks in #gentoo-prefix on
irc.gentoo.org, gentoo-alt@lists.gentoo.org mailing list, or file a bug
at bugs.gentoo.org under Gentoo/Alt, Prefix Support. I am defeated.
I am of no use here any more.
Maybe you can find some clues in /scratch/mmokrejs/gentoo/stage2.log
Comment 1 Zac Medico gentoo-dev 2016-06-18 06:09:40 UTC
(In reply to Martin Mokrejš from comment #0)
> !!! /scratch/mmokrejs/gentoo/tmp/etc/portage/make.profile is not a symlink
> and will probably prevent most merges.
> !!! It should point into a profile within
> /scratch/mmokrejs/gentoo/usr/portage/profiles/
> !!! (You can safely ignore this message when syncing. It's harmless.)

The KeyError is a result of the above problem. Apparently $EPREFIX/etc/portage/make.profile does not point to a valid profile.

The profile_check function inside pym/_emerge/main.py needs to be fixed to identify this case. It seems that root_trees["root_config"].settings.profiles is non-empty, even though root_trees["root_config"].settings.profile_path is None. Both the profiles and profile_path attributes come from the LocationsManager class. We should probably fix LocationsManager so that the profiles attribute is always empty when the profile_path attribute is None.
Comment 2 Zac Medico gentoo-dev 2016-06-21 06:26:41 UTC
Using the master branch of portage, the profile_check function works properly, causing it to bail out before the KeyError would occur. Tested with v2.2.28 and current master branch, it bails out as follows:

!!! /etc/portage/make.profile is not a symlink and will probably prevent most merges.
!!! It should point into a profile within /usr/portage/profiles/
!!! (You can safely ignore this message when syncing. It's harmless.)


!!! Your current profile is invalid. If you have just changed your profile
!!! configuration, you should revert back to the previous configuration.
!!! Allowed actions are limited to --help, --info, --search, --sync, and
!!! --version.
Comment 3 Zac Medico gentoo-dev 2016-06-21 18:01:31 UTC
It's reproducible with the master branch when /etc/portage/make.profile is an empty directory.
Comment 4 Zac Medico gentoo-dev 2016-06-21 18:52:27 UTC
We've got this ARCH sanity check in pym/_emerge/Scheduler.py, which we can move to profile_check function in pym/_emerge/main.py:

https://gitweb.gentoo.org/proj/portage.git/commit/?id=df2c91cfdfbb827b61d4d3b7de6817a9ccd31a5d
Comment 5 Larry the Git Cow gentoo-dev 2017-12-02 22:54:43 UTC
The bug has been referenced in the following commit(s):

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

commit a544824d5f62d26b08826c991275ed8e0e70f525
Author:     Zac Medico <zmedico@gentoo.org>
AuthorDate: 2017-12-02 22:26:49 +0000
Commit:     Zac Medico <zmedico@gentoo.org>
CommitDate: 2017-12-02 22:33:06 +0000

    profile_check: detect missing ARCH variable (bug 586214)
    
    The Scheduler._env_sanity_check method executed too late
    to prevent a KeyError for ARCH in getmaskingstatus, so
    use profile_check to detect missing ARCH and exit earlier.
    
    Bug: https://bugs.gentoo.org/586214

 pym/_emerge/Scheduler.py             | 36 ------------------------------------
 pym/_emerge/main.py                  |  3 ++-
 pym/portage/package/ebuild/config.py |  4 +++-
 3 files changed, 5 insertions(+), 38 deletions(-)}
Comment 6 Zac Medico gentoo-dev 2017-12-11 17:38:37 UTC
*** Bug 640676 has been marked as a duplicate of this bug. ***
Comment 7 Oleg 2018-01-08 12:37:31 UTC
I got this error with crossdev when /usr/mipsel-hardfloat-linux-uclibc/etc/portage/make.profile points to /usr/portage/profiles/embedded