Project:Portage/Fixing broken portage

This article Article description::provides guidance on how to manually update or fix a broken Portage installation - particularly in the event cannot be run. While not hard it is still to be done with great care, so please follow the listed steps a closely as possible, but apply common sense when necessary.

Modern guidance
In emergencies, it is possible to run Portage directly from an extracted tarball. This is often required if it's not possible to run the current version of Portage to emerge packages at all. This advice is based on the testing Portage tips for developers.

Fetch Portage
Go to portage.git and download the latest tarball from the tags/download section. At time of writing, this is Portage 3.0.44.

Extract the tarball:

Set up the environment
Temporarily set up the environment:

Test emerge
It is time to run emerge: it may be possible to run simply, but it is recommended to prefix with the full path to be sure, as below.

Upgrading the system safely
Proceed to upgrade Portage itself (if this fails, which is fairly likely, don't worry about it):

Check the version of Bash. This is necessary for newer EAPIs. If it is older than 5.0, forcefully upgrade it:

Attempt a full world upgrade:

Possible failures with older Bash
If <= Bash 5.0 isn't installed, EAPI 8 won't be usable, giving errors like: * Messages for package dev-qt/qtcore-5.15.2-r10:

* ERROR: dev-qt/qtcore-5.15.2-r10::gentoo failed (pretend phase): *  >=bash-5.0 is required * * Call stack: *  ebuild.sh, line 54:  Called __check_bash_version *  ebuild.sh, line 35:  Called die * The specific snippet of code: *             die ">=bash-${maj}.${min} is required"

In this case, try: .

Very old versions of Portage or Python (pre 2.7)
In very unusual (Gentoo archeology!) cases, the Ancient page may be useful.