Anki Mozc Failures

Just a quick note for fellow users of the Anki SRS software specifically running on Linux. Since my update to Jammy (Ubuntu 22.04) a while back, I ran into an issue where some subsets of words or input combinations would cause ibus to barf with rather annoying consequences. Until this last week, this would only manifest when typing a specific subset of katakana words.

Typing ใ‚นใƒซ for example, would die right after typing the ’s’, and then the input manager would start typing directly in Latin characters until I re-invoked all of the keyboard shortcuts to effectively restart mozc and ibus.

Fast forward to today, and non-katakana words starting with ’m’ started giving me grief. As it turns out, this is a bug in mozc that was fixed sometime last year. Thank you to one mvf on this thread on the Anki Web forums. Their guidance indicated the bump to somewhere around mozc 2.26.4472 would clear up the issue.

The default version of the mozc packages that ship with jammy are out of date, but fortunately a new enough version has been brought into Jammy backports for use.

The Fix

To get said fix without any shenanigans, I needed to:

  1. enable jammy-backports
  2. define the “pinning” behavior for the mozc family of packages
  3. update, and re-login.

Enable Backports

The following assumes you’re a KDE user, but the fix should work just as well if you’re using gedit, nano, vi, or emacs.

Open up a new text file to add the backports line

kate /etc/sources.list.d/jammy-backports

And add the jammy-backports repo. Strictly speaking you only need universe here, but with the package pinning we’re about to setup none of the non-mozc packages should be affected

deb http://archive.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiverse

Enable Pinning for the mozc packages

Open a configuration file for the pinning of packages.

kate /etc/apt/preferences.d/52-backports-jammy-manual

In my case, I wrote some verbose comments for future me. The wildcards on line 5 below will capture (as of writing) 10 packages in the ubuntu repositories. I’ve only got 8 of the packages installed. The syntax is described ab it more in this debian/ubuntu documentation. In my case I’m saying any package that has a name matching the wildcard syntax on line 5, should utilize a package contained in the archive (because of the a= syntax) named jammy-backports with a priority of 500. A priority of 500 means (per the documentation linked above) obey the pinning if the version of the package in the pinned repo is newer than the version requested otherwise.

Because I’ve put the source definition in sources.list.d the backport should be automatically disabled when I upgrade to 24.04 sometime next year, but in the event that fails for some reason, the pinning configuration here should prevent me from being stuck on an “old” version in the jammy-backports repo, assuming there is a newer version of the mozc packages in the mainline repository.

# Added 2023-10-06 to bring in a Mozc backport to fix a really annoying bug
# where Anki would lose MOZC imput some times. Notably when typing ใ‚นใƒซ but
# suddenly also when typing words that sart with "m"

Package: mozc-* *-mozc *-mozc-*kate
Pin: release a=jammy-backports
Pin-Priority: 500

Update and profit

At this point you can use your usual update mechanisms. In my case this was first to check that this was going to upgrade only the 8 mozc packages a had installed, then to invoke the KDE neon upgrader, log-out, and log-back in.

sudo apt update
sudo apt list --upgradable

Inspect the listing above. It was good for me, so I ran the update

sudo pkcon update

Finally!

Low and behold, my woes are fixed.


Last modified on 2023-10-06