TMUX Version Mismatch

Just a quick hack/workaround this time: I set up a new Amazon EC2 instance last night, and decided to upgrade it from the default Ubuntu 14.04 to the latest version 15. Naturally I updated everything first, with sudo apt-get update && sudo apt-get dist-upgrade -y (NB: I'm using dist-upgrade because I don't have any need for the system to be stable. If I did, I wouldn't be making the 14->15 transition at all; but bear in mind that dist-upgrade can break some backwards-compatibility if you're not careful.)

I'm accessing this server over SSH, so without thinking I run the sudo do-release-upgrade from my stock ZSH prompt. After a few seconds gathering info from various locations, it halts the installation and warns me of the dangers of installing over SSH. I take the hint and cancel the installation as recommended, open a new TMUX session and re-run sudo do-release-upgrade. I figure it's gonna take a bit of time, so I detach, close the SSH session and go watch some Unbreakable Kimmy Schmitt.

After a few episodes, I come back and SSH into the server again, just to check on its progress. I try and attach to the session again with tmux a, and get this error message:

protocol version mismatch (client 8, server 7)  

So... that's a problem. Doing a release upgrade has installed a new, backwards-incompatible version of TMUX (both server and client). I'm trying to run the new version of the client, and attach to the still-running old server process -- which isn't working.

I turn to unix.SE, and find an awesome solution pretty much immediately! What it recommends doing is finding the currently running tmux executable, and using it to attach to the running server. It does this with just two commands: pgrep tmux to find the PID, and /proc/<PID>/exe attach to run the old TMUX executable with the "attach" argument. Lucky for me this worked: the installation was paused at a menu screen, so killing the session in the hope that the instalation was finished could have been disastrous.

Cool hack -- and it's the kind of thing that only a UNIX-like system can do, where pretty much everything quacks like a file.