In the process of upgrading my PostgreSQL from version 9.2.4 to 9.3.1 (via homebrew on OS X) I came across an odd problem. These are the steps I took so far
I recently ran into this problem and re-installing postgis worked for me. That is, go to the folder in which you tar'ed the source file (if you installed postgis from source) and re-run:
./configure
make
sudo make install
If you've installed the latest version of postgresql, postgis should install into the new postgresql's extension folder:
/usr/share/postgresql/x.x/extension/
To check, run:
sudo su -l postgres
psql template1 -p 5433
SELECT name, default_version,installed_version
FROM pg_available_extensions WHERE name LIKE 'postgis%' ;
If postgis has successfully installed, you should see the version number indicated in the "installed" column. Now when you try running the pg_upgrade command, everything should work fine.
Hope this helps.