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:
 *     ebuild.sh, line 133:  Called pkg_preinst
 *   environment, line 3238:  Called die
 * The specific snippet of code:
 *       env -u DISTDIR -u PORTAGE_OVERRIDE_EPREFIX -u PORTAGE_REPOSITORIES -u PORTDIR -u PORTDIR_OVERLAY PYTHONPATH="${D%/}${PYTHON_SITEDIR}${PYTHONPATH:+:${PYTHONPATH}}" "${PYTHON}" -m portage._compat_upgrade.default_locations || die;
 * 
 * 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 https://anongit.gentoo.org/git/proj/portage.git
/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).
Keep on reading!

Compilation failure with Value too large for defined data type in Gentoo

It has happened several times for the last 10 years, a program to fail during the configure stage with a strange error:

checking whether we are cross compiling...  * /var/tmp/portage/sys-apps/sandbox-2.12/work/sandbox-2.12/libsandbox/libsandbox.c:check_syscall():968: failure (Value too large for defined data type):
 * ISE: fopen_wr(conftest.out)
        abs_path: (null)
        res_path: /var/tmp/portage/sys-apps/sandbox-2.13/work/sandbox-2.13-abi_x86_32.x86/conftest.out
configure: error: in `/var/tmp/portage/sys-apps/sandbox-2.13/work/sandbox-2.13-abi_x86_32.x86':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details

It’s like the “./conftest” is made and the execution failed?

Last package it happened was when trying to build

sys-apps/sandbox-2.13

but it is not especially related to this Gentoo package or even to Gentoo!

And the debug.log is not informative neither:

configure:3793: ./conftest
/usr/lib32/libsandbox.so(+0xb238)[0xf7738238]
/usr/lib32/libsandbox.so(+0xb2c7)[0xf77382c7]
/usr/lib32/libsandbox.so(+0x40b1)[0xf77310b1]
/usr/lib32/libsandbox.so(+0x421e)[0xf773121e]
/usr/lib32/libsandbox.so(fopen+0x55)[0xf7733e45]
./conftest(+0x4a1)[0x565754a1]
/lib32/libc.so.6(__libc_start_main+0xf6)[0xf7561956]
./conftest(+0x508)[0x56575508]
/proc/23882/cmdline: ./conftest 

/var/tmp/portage/sys-apps/sandbox-2.13/work/sandbox-2.13/configure: line 3795: 23882 Aborted                 ./conftest$ac_cv_exeext
configure:3797: $? = 134
configure:3804: error: in `/var/tmp/portage/sys-apps/sandbox-2.13/work/sandbox-2.13-abi_x86_32.x86':
configure:3806: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details

After some debugging it turned out the problem was the

XFS filesystem

The root was formatted with XFS and therefore

/var/tmp/portage

where all the compilation occurred was on a xfs formatted partition!
It is easy to resolve the issue, just mount your “/var/tmp/portage” on another filesystem, if you do not have any spare devices or places with other filesystem, you could always mount it using

tmpfs

(using your memory for the directory) like this:

mount -t tmpfs -o size=4096m tmpfs /var/tmp/portage/

You can adjust the size with “size” parameter, but most of the program require a way below 4G of space. And do not forget mounting your build directory in the tmpfs speeds up the emerge process significantly!

And probably it is a good idea before mounting it to delete all old sub-directories, because they can take much space and they are left there after failed compilations of packages.

rm -R /var/tmp/portage/*

PS: It was the same with compilation of

sys-devel/gcc-7.3.0

configure: updating cache ./config.cache
 * /var/tmp/portage/sys-apps/sandbox-2.13/work/sandbox-2.13/libsandbox/libsandbox.c:check_syscall():968: failure (Value too large for defined data type):
 * ISE: fopen_wr(conftest.val)
        abs_path: (null)
        res_path: /var/tmp/portage/sys-devel/gcc-7.3.0/work/build/x86_64-pc-linux-gnu/32/libgomp/conftest.val
configure: error: unsupported system, cannot find sizeof (omp_lock_t)
make[2]: *** [Makefile:20106: configure-stage1-target-libgomp] Error 1
make[2]: Leaving directory '/var/tmp/portage/sys-devel/gcc-7.3.0/work/build'
make[1]: *** [Makefile:22189: stage1-bubble] Error 2
make[1]: Leaving directory '/var/tmp/portage/sys-devel/gcc-7.3.0/work/build'
make: *** [Makefile:22521: bootstrap-lean] Error 2
 * ERROR: sys-devel/gcc-7.3.0::gentoo failed (compile phase):
 *   emake failed
 * 
 * If you need support, post the output of `emerge --info '=sys-devel/gcc-7.3.0::gentoo'`,
 * the complete build log and the output of `emerge -pqv '=sys-devel/gcc-7.3.0::gentoo'`.
 * The complete build log is located at '/var/tmp/portage/sys-devel/gcc-7.3.0/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/sys-devel/gcc-7.3.0/temp/environment'.
 * Working directory: '/var/tmp/portage/sys-devel/gcc-7.3.0/work/build'
 * S: '/var/tmp/portage/sys-devel/gcc-7.3.0/work/gcc-7.3.0'
 * 
 * Please include /var/tmp/portage/sys-devel/gcc-7.3.0/work/gcc-build-logs.tar.bz2 in your bug report.
 * 

>>> Failed to emerge sys-devel/gcc-7.3.0, Log file:

The problem is the same, compiling on

XFS filesystem