Failed to install sys-apps/portage – Called pkg_preinst – portage._compat_upgrade.default_locations

Recently there was a problem with one compute node servers, which Gentoo (in fact, the chroot environment had not been updated for 3 years) could not emerge the new portage because it kept failing in the pkg_preinst with:

srv ~ # USE="-rsync-verify" emerge -va '=sys-apps/portage-2.3.76::gentoo'
>>> Installing (1 of 1) sys-apps/portage-2.3.76::gentoo
 * checking 1999 files for package collisions
1000 files checked ...
^[[B>>> Merging sys-apps/portage-2.3.76 to /
/usr/bin/python2.7: No module named _compat_upgrade
 * ERROR: sys-apps/portage-2.3.76::gentoo failed (preinst phase):
 *   (no error message)
 * Call stack:
 *, line 133:  Called pkg_preinst
 *   environment, line 3238:  Called die
 * The specific snippet of code:
 * If you need support, post the output of `emerge --info '=sys-apps/portage-2.3.76::gentoo'`,
 * the complete build log and the output of `emerge -pqv '=sys-apps/portage-2.3.76::gentoo'`.
 * The complete build log is located at '/var/tmp/portage/sys-apps/portage-2.3.76/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/sys-apps/portage-2.3.76/temp/environment'.
 * Working directory: '/var/tmp/portage/._portage_reinstall_.RKkxLW/pym'
 * S: '/var/tmp/portage/sys-apps/portage-2.3.76/work/portage-2.3.76'
!!! FAILED preinst: 1

>>> Failed to install sys-apps/portage-2.3.76, Log file:

>>>  '/var/tmp/portage/sys-apps/portage-2.3.76/temp/build.log'

Note this is the installation phase, where everything from the build process passes smoothly, but it fails to install it with some vague error of a dying line with a couple of python and portage environments. The problem is the current portage does not support EAPI 6 and 7 and some packages were unable to be installed!

And we fixed the issue by just using the method described in our previous article – Fix your broken or old portage in Gentoo, fix the emerge command
Cloning a new portage software and using it to emerge (install) a newer (or reinstall the current) portage in the system to fix the system’s portage and the emerge command:

cd /root
git clone
/root/portage/bin/emerge --sync
eselect profile set default/linux/amd64/17.1
/root/portage/bin/emerge -v portage

Now the latest and stable Gentoo profile is 17.1, so we set it to be sure we use it (in future this may change).

Here is the output of fthe commands above:

srv ~ # git clone
Cloning into 'portage'...
remote: Enumerating objects: 151644, done.
remote: Counting objects: 100% (151644/151644), done.
remote: Compressing objects: 100% (41427/41427), done.
remote: Total 151644 (delta 112565), reused 148195 (delta 109827)
Receiving objects: 100% (151644/151644), 24.29 MiB | 18.23 MiB/s, done.
Resolving deltas: 100% (112565/112565), done.
Checking connectivity... done.
srv ~ # ./portage/bin/emerge --sync
>>> Syncing repository 'gentoo' into '/usr/portage'...
 * Using keys from /usr/share/openpgp-keys/gentoo-release.asc
 * Refreshing keys via WKD ...                                                                                                                                       [ ok ]
>>> Starting rsync with rsync://
>>> Checking server timestamp ...
Welcome to /
=== Sync completed for gentoo

Action: sync for repo: gentoo, returned code = 0
srv ~ # eselect profile set default/linux/amd64/17.1
srv ~ # ./portage/bin/emerge -v portage

 * IMPORTANT: 2 config files in '/etc/portage' need updating.
 * sections of the emerge man page to learn how to update config files.

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

Calculating dependencies... done!
[ebuild  N     ] app-crypt/openpgp-keys-gentoo-release-20190427::gentoo  USE="-test" 59 KiB
[ebuild  N     ] dev-python/bz2file-0.98::gentoo  PYTHON_TARGETS="python2_7 -pypy" 12 KiB
[ebuild     U  ] dev-libs/libgpg-error-1.36::gentoo [1.21::gentoo] USE="nls -common-lisp -static-libs (-threads%*)" ABI_X86="(64) -32 (-x32)" 899 KiB
[ebuild     U  ] dev-libs/libgcrypt-1.8.5:0/20::gentoo [1.6.5:0/20::gentoo] USE="-doc -o-flag-munging% -static-libs (-threads%*)" ABI_X86="(64) -32 (-x32)" 2,922 KiB
[ebuild     U  ] dev-libs/libassuan-2.5.3::gentoo [2.4.2::gentoo] USE="-static-libs" 559 KiB
[ebuild     U  ] dev-libs/libksba-1.3.5-r2::gentoo [1.3.3::gentoo] USE="-static-libs" 607 KiB
[ebuild     U  ] app-crypt/gnupg-2.2.17::gentoo [2.1.11-r1::gentoo] USE="bzip2 nls readline smartcard* ssl%* -doc -ldap (-selinux) -tofu -tools -usb -user-socket% -wks-server% (-gnutls%) (-static%)" 6,561 KiB
[ebuild  N     ] app-portage/gemato-14.1::gentoo  USE="blake2 bzip2 gpg -lzma -sha3 -test -tools" PYTHON_TARGETS="python2_7 -pypy -python3_5 -python3_6 -python3_7" 70 KiB
[ebuild     U  ] sys-apps/portage-2.3.76::gentoo [2.2.28::gentoo] USE="(ipc) native-extensions%* rsync-verify%* xattr -build -doc -epydoc -gentoo-dev% (-selinux) (-linguas_ru%)" PYTHON_TARGETS="python2_7 -pypy -python3_5 -python3_6% -python3_7% (-python3_3%) (-python3_4%*)" 0 KiB

Total: 9 packages (6 upgrades, 3 new), Size of downloads: 11,685 KiB

The portage from the git was the latest version and knows the packages with EAPI 7 and even we did not need the USE=”-rsync-verify” this time. Our old portage version was “2.2.28” – at least 3 years old, not knowing for the EAPI 6 and 7 limiting the ability to install those packages, too.

Leave a Reply

Your email address will not be published. Required fields are marked *