Home / Alt manpages / update-dictcommon-hunspell(8)

  • update-dictcommon-hunspell(8)
  • Admin command
  • linux

Repair Hunspell's dictionaries-common Database Safely

update-dictcommon-hunspell rebuilds the Hunspell database and related Emacs and SquirrelMail support files used by Debian's dictionaries-common package. This guide shows how to decide whether it is the right repair, record the installed version, and run it with a recovery plan.

Allow about 10 minutes. You need a shell, the dictionaries-common package, and root access for the repair itself. The installed command is version 1.29.7 on the system documented here.

1. Confirm the package and command

Start with read-only checks. They confirm that the command belongs to the expected package and show where the executable is installed.

$ 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 using 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 is under /var/cache/dictionaries-common. That 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. First identify the package operation or damaged generated data that justifies the rebuild.

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. That is useful evidence, not something to force into a fixed layout. If dpkg-query reports an interrupted package operation, finish diagnosing that operation 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. It does not offer a dry-run flag or an 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 is generated by mktemp, so your path will be different. Keep it until validation is complete and protect it if the cache contains 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 when you have accepted its package-wide effect. It requires elevated privileges; an ordinary user invocation fails before rebuilding anything.

$ sudo /usr/sbin/update-dictcommon-hunspell

A successful run normally has no useful report to display. The command may print nothing and return to the shell. Check its exit status immediately:

$ printf 'exit status: %s\n' "$?"
exit status: 0

If you see You must run this as root, the command was not run with 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 that the cache still exists, that its files have current timestamps, and that 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 that 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, reopen the affected editor or webmail session and perform 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

Restoring a cache can reintroduce stale data, so treat it as a temporary recovery 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-common is installed and its version is recorded.
  • You identified a real package or generated-cache reason for the rebuild.
  • You made a recovery copy before using root privileges.
  • update-dictcommon-hunspell returned exit status 0.
  • /var/cache/dictionaries-common/hunspell.db is non-empty and the affected spellchecker works.