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 doesn't work for you anymore it may still be possible to use it to fetch the tarball for you, so as a first step try to run, only if that doesn't work you have to manually fetch the tarball with:

 Fetching portage tarball with wget 

After that you should have the tarball 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 you have done this, it's just a matter of replacing the python and bash files of your existing installation with the ones from the tarball (in most cases anyway). To do so, run:

 Replacing installed files 

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

 Removing the sed wrapper script 

Now you should have a working Portage install again. To ensure a consistent system state however, you should now run  again immediately.

If you get a 'command not found' error message when you try to run, you have to recreate the symlink:

Recreating the emerge symlink

If these steps didn't work for you your 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.