Project:Portage/Fixing broken portage

Purpose
This section will tell you how to manually update/fix your Portage installation in case you can't run. While not hard it is still to be done with great care, so please follow the listed steps exactly (but apply common sense when necessary).

Modern guidance
In emergencies, it's 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/downlod section. At time of writing, this is Portage 3.0.26.

Extract the tarball

Temporarily set up the environment

Run emerge

It may be possible to run simply, but it is recommended to prefix with the full path to be sure.

Proceed to upgrade Portage itself, but if that fails, attempt a full world upgrade.

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