I don't know why, but somehow, an incorrect version of a package got installed. Here's the story of how I fixed it using all the tricks in the book to get unstuck. Alternate title: "how messing up your system so many times over the years helps you fixing it... eventually".
The last time this happened to me must have been about two decades ago when I installed Debian for the first time, trying to see how "apt-get" fared against Mandrake's "urpmi" and eventually coming to the conclusion that Gentoo's "emerge" was better (ah, the naivety of youth).
So this time, I wanted to install that very innocuous "-dev" package and it threw an error like so. (I haven't bothered translating the messages. If you can't understand from the context, ask DeepL.)
Ok, it happens. It's usually either because you're trying to install something that is truly not compatible with your system or you just have stale repositories indexes. Knowing that a "-dev" package is rarely a problem especially since I didn't even specify a version, I went ahead with the regular "apt update" and "apt upgrade" process.
No luck, same error. So I asked my trusty "apt-cache policy" what was the matter with "libx11-6":
First thing, I like to live dangerously and ignore Debian's warning regarding having an unstable source. Still, that couldn't be the source of the error because I had pinned it's priority to 10 (very much lower so only to be installed when requested explicitely). Second thing, where is that "1.8.6" version even coming from? Not sure, but to be safe, I cleaned my apt sources as much as I could and tried again the "update" then "upgrade" process. No luck: the version was indeed higher, so the usual priority stuff didn't work, that is to say 400 is higher than 100, but 1.8.6 is higher than 1.8.4.
So, I knew I needed to install the "1.8.4" version instead so I just tried requesting it explicitely:
And the result would be to remove almost every graphical program installed... Figures: something called "libx11" is probably linked in some way to every GUI in the system. So I needed a smarter tool becase I wasn't actually removing the library, only replacing it. I first turned to my aptitude (not my technical ability, the program). It sometimes comes up with a plan to get unstuck. It's a lazy solution, but if it works, why not try? But it didn't. To be faire, I haven't heard about aptitude for a while. It is still a perfectly valid program, but "apt" has gotten good enough that "getting automatically unstuck" is not a feature in very high demand.
At that point, I had to resort to the tool of ultimate necessity, the quintessential footgun, the "with power comes great responsibilty... just kidding don't even try" solution: "dpkg". Ok, in most case, it would have been a bad idea to do this, but I knew I merely wanted to remove a library and replace it with the same one, tow minor versions down. So here goes:
Exit code 0. Done.