I just had quite a nice scare: I was installing some packages on Pop!_OS 18.10 (Ubuntu), and I unknowingly caused my trackpad to stop working and I couldn’t even open a Terminal window to see what was happening.
I had been installing some packages with
apt. At one point, when I tried to take the next step, I tried to open a new window in Byobu Terminal. I pressed
F2 and nothing happened. I tried again, and nothing happened. I couldn’t open a new window. I tried
Ctrl+F2, but neither of these key combinations did anything. I closed my Byobu Terminal session and tried to open a new one, but launching Byobu did nothing. No window opened.
Next, I tried launching the regular Terminal application. Again, no window. Nothing. I tried XTerm. Nothing. I couldn’t open a Terminal session at all! How the hell was I going to even get information to help me diagnose the problem?
I tried logging out, then logging in again. I couldn’t open any Terminal windows and, worse, I couldn’t use my trackpad! My trackpad didn’t move my cursor at all. This would make figuring out the problem very difficult.
I tried restarting the computer. No change: I couldn’t open a Terminal window and I couldn’t use my trackpad.
I couldn’t see any output from trying to start a Terminal session, so I had no idea how to even guess at the symptoms, let alone the cause. How could I start a shell and see the result of trying to start one? And how do I get around my windowing environment without a trackpad?
Fortunately, I had a USB mouse nearby, so I plugged that in and it just worked. This meant that I could at least browse the web on this computer to figure out what else to do. I searched the web and tried using
Alt+F2 to run an arbitrary command (in Gnrome 3), so I ran
gnome-terminal. This didn’t open a Terminal session and it showed me no output, so I didn’t learn anything about the problem.
In desperation, I launched GVim, then tried using the
:! command to run a shell. This finally gave me a clue:
apt fooled me.
The Trouble With
I had been trying to install some printer-related packages, and in the process of uninstalling them (they didn’t do what I needed),
apt told me that it could
autoremove these packages:
Since I didn’t know any better, I executed
apt autoremove, which removed these packages, and my problems started there.
etckeeper made it relatively easy both to recover and to document what went wrong. I could see a commit from when I removed the printer-related packages that I’d installed, and then a second commit from executing
apt autoremove. This helped me connect the error message above with the packages that I’d removed. This gave me the idea that I could simply reinstall those packages and return everything to normal.
Opening A Shell… Any Shell
I couldn’t open my normal shell (
zsh) to fix the problem, but could I open any shell? I opened the Preferences for the Terminal application, then cloned my Pop! profile in order to change the shell command that the terminal runs to
/bin/bash. I set the new profile—I called it “Recovery”—as the default profile for the Terminal application, then launched it. Yes! I got a
bash shell. Now I could try my idea for fixing the problem.
After reading https://askubuntu.com/a/809058/839487 I saw that I could have started
bash instead of my shell by pressing
Alt+F2 then running the command
gnome-terminal -x bash. I hope I can remember this next time!
Fixing The Problem
I fixed the problem (some of it—keep reading) by reinstalling the packages that
apt autoremove had removed.
I could open a shell again. Maybe everything had returned to normal. Before I did anything else, I documented what I learned where I might one day stumble upon it again: in the
git log for
Documenting The Problem
I amended the relevant
etckeeper commits, adding detail about what happened, as well as making it easier for the eye to notice that something interesting had happened. First, I decorated the one-line commit messages.
$ cd /etc $ sudo git log --graph --all --oneline * c2efaa2 (HEAD) [FIX] committing changes in /etc after apt run * 8866206 [MISTAKE] committing changes in /etc after apt run | * 4c984ec (offsite-backup/master, master) committing changes in /etc after apt run | * 984c8eb committing changes in /etc after apt run |/ * 2945f32 committing changes in /etc after apt run * 81410e8 saving uncommitted changes in /etc prior to apt run
The last two commits contained the mistake (
apt autoremove and the fix
apt-get install...). I added simple text tags to make it easier to spot them. I also added some detail to the log messages.
$ sudo git log --all commit c2efaa27381fa9a3afcb5426c44a7577a6cc01de (HEAD) Author: J. B. Rainsberger <email@example.com> Date: Thu Jan 17 10:33:36 2019 -0400 [FIX] committing changes in /etc after apt run Reinstalling these packages fixes the previous action `apt autoremove`. Package changes: +libncursesw5 6.1+20180210-4ubuntu1 amd64 +libtinfo5 6.1+20180210-4ubuntu1 amd64 commit 8866206fa2b6ff42a10d0d05e83da2eefaf44424 Author: J. B. Rainsberger <firstname.lastname@example.org> Date: Thu Jan 17 10:16:53 2019 -0400 [MISTAKE] committing changes in /etc after apt run `apt autoremove` removed these packages, but after I did that, I could no longer open my shell (zsh), even though I could open bash. Trying to launch zsh resulting in an error, unable to find libtinfo.so.5. I don't know why this happened, but reinstalling these two packages seemed to fix the problem. Package changes: -libncursesw5 6.1+20180210-4ubuntu1 amd64 -libtinfo5 6.1+20180210-4ubuntu1 amd64
I had documented my adventures for myself and could safely breathe, then begin describing my adventures for you, in case you should ever get yourself into a similar situation.
Verifying The Fix
I could start my shell again, but my trackpad still didn’t work, so I got all this information out of my head, then I tried to see whether my trackpad would work again, first by logging out, then by rebooting in case logging it didn’t suffice.
Curiously, when I logged out, my trackpad started to work again, but when I logged in, it stopped working. Moreover, each time I tried this, the cursor jumped to the same spot near the bottom-right corner of my display. I didn’t know what that meant yet, but it made me think that I had some configuration setting somewhere that needed to change. I hoped that rebooting would fix the problem, so I rebooted.
Sadly, that didn’t fix the entire problem. Good news: I can start my shell and Byobu. Bad news: my trackpad only works when I’m logged out. This points pretty clearly to a user-level configuration problem, which I can probably diagnose (and maybe fix) by looking at the changes to
/etc or to my
dotfiles when I reinstalled these packages. Fortunately, in the meantime, a USB mouse works, so I don’t have to fix this problem right now, even though I’ll want to fix it very soon.
Post Script: Fixing the Touchpad
I guess Linux calls it a “touchpad” and not a “trackpad”. Old habits die hard.
I don’t know how it happened, but somehow, in the middle of removing and reinstalling packages, the “on/off” toggle for the touchpad in Gnome switched to “off”. That’s all. I switched it back “on” through the Mouse & Touchpad settings, and the touchpad just started working again. Yay.