Project:Portage/Fixing broken portage

From Gentoo Wiki
Jump to:navigation Jump to:search

Purpose

This section will tell you how to manually update/fix your Portage installation in case you can't run emerge -v1 sys-apps/portage. 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

Warning
If only Python 2.7 is installed, leap-frogging will be required by using portage-2.3.103 (the last version to support Python 2.

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.22.

Extract the tarball

root #mkdir -p /tmp/portage && cd /tmp/portage
root #tar xvf portage-3.0.22.tar.gz -C /tmp/portage --strip-components=1

Temporarily set up the environment

root #export PYTHONPATH="/tmp/portage/lib${PYTHONPATH:+:}${PYTHONPATH}"
root #export PATH="/tmp/portage/bin:${PATH}"

Run emerge

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

root #bin/emerge --info

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.