Repair Hunspell's dictionaries-common Database Safely
A spellchecker flags every word after a dictionary change, and update-dictcommon-hunspell is the hook that rebuilds the database behind it.
The route
Jump straight to the step you need, or tick off Done means at the end.
It rebuilds the Hunspell database and related Emacs and SquirrelMail support files used by Debian's dictionaries-common package. This guide covers deciding whether it is the right repair, recording the installed version, and running it with a recovery plan.
- Time: about 10 minutes.
- Needs: a shell, the
dictionaries-commonpackage, and root access for the repair itself. The installed command documented here is version 1.29.7.
1. Confirm the package and command
Start with read-only checks. They confirm the command belongs to the expected package and show where the executable lives.
$ dpkg-query -W -f='${Package} ${Version}\n' dictionaries-common
dictionaries-common 1.29.7
$ command -v update-dictcommon-hunspell
/usr/sbin/update-dictcommon-hunspell
The version line may differ on another Debian release. Treat that difference as a boundary: read the matching local manual page before relying on details from this guide.
Checkpoint
Continue only if the package is installed and the command resolves to the package-managed executable.
2. Understand what the command is for
The manual page describes this program as a hook for a Hunspell dictionary package's postinst or postrm action. It is not a general-purpose Hunspell configuration command, and the manual explicitly warns against running it from the command line unless you know why it is needed.
On this installation, the wrapper checks for root, rebuilds the hunspell class database, then regenerates support data for Emacs and SquirrelMail. The generated cache sits under /var/cache/dictionaries-common, which includes the Hunspell database and generated support files, so a run can affect spellchecking integrations even when no dictionary package is being installed.
Do not use this command to select a preferred language, test whether Hunspell can spell a word, or repair an unrelated editor problem. Identify the package operation or damaged generated data that justifies the rebuild first.
3. Check the failure before changing state
Read the command's local documentation and inspect package status before running a privileged repair.
$ man 8 update-dictcommon-hunspell
$ dpkg-query -s dictionaries-common | sed -n '1,12p'
$ ls -ld /var/cache/dictionaries-common
$ ls -l /var/cache/dictionaries-common
The last two commands may show a different set of files on a different installation. Treat that as useful evidence, not something to force into a fixed layout. If dpkg-query reports an interrupted package operation, diagnose that first: rebuilding a derived cache will not repair a broken package transaction.
Checkpoint
You should now have a concrete reason for rebuilding and a record of the current package and cache state.
4. Make a small recovery copy
The command regenerates derived files with no dry-run flag and no undo option. Before changing them, copy the existing cache directory to a private temporary location with enough space.
$ backup_dir=$(mktemp -d /tmp/dictionaries-common-backup.XXXXXX)
$ cp -a /var/cache/dictionaries-common/. "$backup_dir"/
$ printf 'Backup: %s\n' "$backup_dir"
Backup: /tmp/dictionaries-common-backup.XXXXXX
The printed suffix comes from mktemp, so your path will differ. Keep it until validation is complete, and protect it if the cache holds information that should not be readable by other users.
This copy is a rollback aid for files under the cache directory only. It does not undo a package install or remove an incorrectly installed dictionary.
5. Run the rebuild deliberately
Only run the command once you have accepted its package-wide effect. It needs elevated privileges; an ordinary user invocation fails before rebuilding anything.
$ sudo /usr/sbin/update-dictcommon-hunspell
A successful run normally has nothing useful to display. Check its exit status immediately:
$ printf 'exit status: %s\n' "$?"
exit status: 0
If you see You must run this as root, the command lacked sufficient privilege. If it reports a file, permission, or parsing error, do not repeatedly rerun it: record the message and inspect the relevant dictionary package and cache path instead.
6. Verify the rebuilt data
Confirm the cache still exists, its files carry current timestamps, and the package remains installed.
$ ls -l /var/cache/dictionaries-common
$ test -s /var/cache/dictionaries-common/hunspell.db
$ printf 'hunspell database: %s\n' "$?"
hunspell database: 0
$ dpkg-query -W -f='${Status}\n' dictionaries-common
install ok installed
The database check is deliberately narrow: it verifies the generated Hunspell database is non-empty, not that every dictionary is correct. Compare the directory listing with the pre-run record and test the application that exposed the problem, for example reopening the affected editor or webmail session for a small spelling check.
Checkpoint
The command returned status 0, hunspell.db is non-empty, and the affected consumer sees the expected dictionaries.
7. Recover from a bad rebuild
Stop if the command fails or the consuming application loses expected dictionaries. Preserve the error output and the post-run listing. If the generated files were the only changed state and your backup is trustworthy, restore the cache contents with root access:
$ sudo cp -a "$backup_dir"/. /var/cache/dictionaries-common/
$ sudo ls -l /var/cache/dictionaries-common
Recovery
Restoring a cache can reintroduce stale data, so treat it as a temporary step. The durable fix is to correct the dictionary package or its metadata, then let the package's normal maintainer action rebuild the cache. Do not delete /var/cache/dictionaries-common blindly: the command relies on that directory and its generated files.
Done means
dictionaries-commonis installed and its version is recorded.- Identified a real package or generated-cache reason for the rebuild.
- Made a recovery copy before using root privileges.
update-dictcommon-hunspellreturned exit status 0./var/cache/dictionaries-common/hunspell.dbis non-empty and the affected spellchecker works.