Project:Portage/Fixing broken portage/Ancient

Getting a Portage tarball
The first step to do is to get the tarball of a current Portage version. In the following text we will use portage-2.2.8 as an example (as this is the current stable version at the time of this writing), please replace that with a version present in the tree if possible.

Depending on the exact reason Portage does not work, it may still be possible to use it to fetch the update tarball, so as a first step try to run. If that does not work then the tarball will need to be to manually fetched.

Fetching portage tarball with :

The tarball should now be available as.

Replacing the installed version
The next step is to unpack the tarball to a temporary location, using for example, the commands to do that are:

Unpacking portage tarball:

After these steps, it is just a matter of replacing the python and bash files of the existing installation with the ones from the tarball (in most cases anyway). To do so, run:

Replacing installed files:

If using Gentoo on FreeBSD, then remove the sed wrapper script since it is not needed and it is known to cause problems with old versions of bash:

Removing the sed wrapper script:

Now Portage should be working again! To ensure a consistent system state however, run again immediately.

If a 'command not found' error message is received when attempting to run, then the symlink will need to be recreated:

Recreating the emerge symlink:

If these steps did not work, then the problem is likely not a broken Portage installation but something else beyond the scope of this document. Please recheck the list of common problems and also look in Bugzilla if the problem is reported there.