36

I'd like to use hunspell to spell check my repo. However when I try to run it I get the following error:

Can't open affix or dictionary files for dictionary named "en_US".

How can I fix this? I'm on a Mac.

Thanks, Kevin

Kevin Burke
  • 61,194
  • 76
  • 188
  • 305

3 Answers3

42

Execute hunspell -D. You should get output like this:

.::/usr/share/hunspell:/usr/share/myspell:
/usr/share/myspell/dicts:/Library/Spelling:

AVAILABLE DICTIONARIES (path is not mandatory for -d option):
/Library/Spelling/en_GB
LOADED DICTIONARY:
/Library/Spelling/en_GB.aff
/Library/Spelling/en_GB.dic

This lists the directories in which hunspell is searching for dictionary files, as well as the dictionaries is has found. If the dictionary en_US isn't listed, you haven't got that particular dictionary installed.

To install a dictionary, search for it in the LibreOffice extension repository. Download it then extract the .aff and .dic files to one of the locations listed by hunspell -D. For example:

# First download dict-en.oxt
unzip dict-en.oxt -d dict-en
cp dict-en/en_GB.aff dict-en/en_GB.dic ~/Library/Spelling/
rm -r dict-en
Divinenephron
  • 756
  • 8
  • 18
  • 1
    Link no longer has .aff or .dic files, just .oxt (Open Office extension). I was able to find them in the Chromium source: chromium/src/third_party/hunspell_dictionaries/en_US.dic – Loren Oct 24 '12 at 01:12
  • 14
    .oxt files are just ZIP files. You can change the extension and open them and retrieve the files. If you do that, you can stay up to date by watching the extension page for updates. – RobDavenport Oct 16 '13 at 17:05
  • Btw, on macOs latest Hunspell is broken. For more see: https://github.com/hunspell/hunspell/issues/608 – serghei Feb 03 '20 at 12:18
  • 1
    I was able to get Hunspell working on macOS by following these answer's instructions, with the exception of the link for the `.aff` and `.dic` files. To get these I followed the instructions found at https://github.com/hunspell/hunspell#usage (minus the hash pin). So in short I used: `wget -O en_US.aff https://cgit.freedesktop.org/libreoffice/dictionaries/plain/en/en_US.aff` and `wget -O en_US.dic https://cgit.freedesktop.org/libreoffice/dictionaries/plain/en/en_US.dic` – dpritch Mar 24 '22 at 15:45
  • Worked for me on Amazon Linux, Downloaded from the following sources and added both to the path "/usr/share/myspell": https://github.com/elastic/hunspell/blob/master/dicts/en_US/en_US.aff and https://github.com/elastic/hunspell/blob/master/dicts/en_US/en_US.dic – Yaser Sakkaf Sep 20 '22 at 07:09
2

I'm using emacs in windows using msys2. I installed following 2 packages:

pacman -S  mingw-w64-x86_64-hunspell-en mingw-w64-x86_64-hunspell

The mingw-w64-x86_64-hunspell-en package install english dictionaries in /mingw64/share/hunspell, but you check if the files (en_US.dic and en_US.aff) are available or not.

Steps:

  1. set the Environment Variable in .bashrc within mysys2. Without DICPATH it was not working for me.

    export DICTIONARY=en_US
    export DICPATH=/d/../msys2/ming164/share/hunspell
    
  2. run hunspell.exe -D

    SEARCH PATH:
    .;... ;...;...
    AVAILABLE DICTIONARIES (path is not mandatory for -d option):
    D:/xx/mysys64/mingw64/share/hunspell/en_AG
    D:/xx/mysys64/mingw64/share/hunspell/en_AU
    ...
    

    Hunspell 1.6.0

pksec
  • 63
  • 7
  • This is perhaps due to a [bug](https://github.com/Alexpux/MINGW-packages/issues/2147). When it's resolved, the workaround shouldn't be needed but still thanks for this. – legends2k Feb 02 '17 at 15:37
0

I was lucky to find my language here: https://extensions.openoffice.org/en/search?query=de_CH&sort_by=field_project_stats_year&sort_order=DESC

And with the comment from @RobDavenport i was able to rename the extension and extract the files. Something i reread at this link and gave it a try. I dropped the .dic .dat and .aff into my ~/Library/Spelling/ folder.

Bernhard Wagner
  • 1,681
  • 12
  • 15
novski
  • 196
  • 1
  • 11