0

I'm running Emacs on MacOS and I installed aspell and its English dictionaries through nix. When I open a file, flyspell throws the following error.

Error enabling Flyspell mode:
(Error: No word lists can be found for the language "en_US".)

When I set ispell-change-dictionary to english and then try to re-enable flyspell mode, flyspell throws this error message instead:

Error enabling Flyspell mode:
(Error: The file "/nix/store/my1hch4x12i5n1ffhlwpb6bpsiajbv3j-aspell-0.60.6.1/lib/aspell/english" can not be opened for reading.)

I don't know if this is actually the problem, but the above suggests to me that in both cases flyspell is not looking in the correct directory for dictionaries, which for nix should be /nix/store/<hash>-aspell-dict-en-<version>/lib/aspell. Would anyone know how I get ispell to look in the right directory?

If it's relevant, running aspell dump dicts from my shell lists all the dictionaries I have installed, but the output of aspell config makes no mention my nix store's aspell-dict-en directory.

edit: here are the requested variable values:

ispell-program-name == "aspell"
ispell-aspell-data-dir == nil
ispell-dictionary == nil
ispell-local-dictionary == nil
ispell-dictionary-alist == ((nil "[[:alpha:]]" "[^[:alpha:]]" "[']" nil
      ("-B")
      nil utf-8)
 ("american" "[[:alpha:]]" "[^[:alpha:]]" "[']" nil
  ("-B")
  nil utf-8)
 ("brasileiro" "[[:alpha:]]" "[^[:alpha:]]" "[']" nil nil nil utf-8)
 ("british" "[[:alpha:]]" "[^[:alpha:]]" "[']" nil
  ("-B")
  nil utf-8)
 ("castellano" "[[:alpha:]]" "[^[:alpha:]]" "[-]" nil
  ("-B")
  "~tex" utf-8)
 ("castellano8" "[[:alpha:]]" "[^[:alpha:]]" "[-]" nil
  ("-B" "-d" "castellano")
  "~latin1" utf-8)
 ("czech" "[[:alpha:]]" "[^[:alpha:]]" "" nil
  ("-B")
  nil utf-8)
 ("dansk" "[[:alpha:]]" "[^[:alpha:]]" "[']" nil
  ("-C")
  nil utf-8)
 ("deutsch" "[[:alpha:]]" "[^[:alpha:]]" "[']" t
  ("-C")
  "~tex" utf-8)
 ("deutsch8" "[[:alpha:]]" "[^[:alpha:]]" "[']" t
  ("-C" "-d" "deutsch")
  "~latin1" utf-8)
 ("english" "[[:alpha:]]" "[^[:alpha:]]" "[']" nil
  ("-B")
  nil utf-8)
 ("esperanto" "[[:alpha:]]" "[^[:alpha:]]" "[-']" t
  ("-C")
  "~latin3" utf-8)
 ("esperanto-tex" "[[:alpha:]]" "[^[:alpha:]]" "[-'`\"]" t
  ("-C" "-d" "esperanto")
  "~tex" utf-8)
 ("finnish" "[[:alpha:]]" "[^[:alpha:]]" "[:]" nil
  ("-C")
  "~list" utf-8)
 ("francais7" "[[:alpha:]]" "[^[:alpha:]]" "[`'^-]" t nil nil utf-8)
 ("francais" "[[:alpha:]]" "[^[:alpha:]]" "[-'.@]" t nil "~list" utf-8)
 ("francais-tex" "[[:alpha:]]" "[^[:alpha:]]" "[-'^`\".@]" t nil "~tex" utf-8)
 ("german" "[[:alpha:]]" "[^[:alpha:]]" "[']" t
  ("-C")
  "~tex" utf-8)
 ("german8" "[[:alpha:]]" "[^[:alpha:]]" "[']" t
  ("-C" "-d" "german")
  "~latin1" utf-8)
 ("italiano" "[[:alpha:]]" "[^[:alpha:]]" "[-.]" nil
  ("-B" "-d" "italian")
  "~tex" utf-8)
 ("nederlands" "[[:alpha:]]" "[^[:alpha:]]" "[']" t
  ("-C")
  nil utf-8)
 ("nederlands8" "[[:alpha:]]" "[^[:alpha:]]" "[']" t
  ("-C")
  nil utf-8)
 ("norsk" "[[:alpha:]]" "[^[:alpha:]]" "[\"]" nil nil "~list" utf-8)
 ("norsk7-tex" "[[:alpha:]]" "[^[:alpha:]]" "[\"]" nil
  ("-d" "norsk")
  "~plaintex" utf-8)
 ("polish" "[[:alpha:]]" "[^[:alpha:]]" "[.]" nil nil nil utf-8)
 ("portugues" "[[:alpha:]]" "[^[:alpha:]]" "[']" t
  ("-C")
  "~latin1" utf-8)
 ("russian" "[[:alpha:]]" "[^[:alpha:]]" "" nil nil nil utf-8)
 ("russianw" "[[:alpha:]]" "[^[:alpha:]]" "" nil nil nil utf-8)
 ("slovak" "[[:alpha:]]" "[^[:alpha:]]" "" nil
  ("-B")
  nil utf-8)
 ("slovenian" "[[:alpha:]]" "[^[:alpha:]]" "" nil
  ("-B" "-d" "slovenian")
  nil utf-8)
 ("svenska" "[[:alpha:]]" "[^[:alpha:]]" "[']" nil
  ("-C")
  "~list" utf-8)
 ("hebrew" "[[:alpha:]]" "[^[:alpha:]]" "" nil
  ("-B")
  nil utf-8))

And the output of aspell dump dicts | grep en_US is:

en_US
en_US-variant_0
en_US-variant_1
en_US-w_accents
en_US-wo_accents
  • 1
    What are the values of: ispell-program-name, ispell-aspell-data-dir, ispell-dictionary-alist, ispell-dictionary, ispell-local-dictionary and, what's the output of aspell dump dicts | grep en_US? – sshaw Jan 18 '18 at 1:51
  • @sshaw, I added the requested info. Sorry for the late response – user110524 Jan 20 '18 at 6:30
1

(Error: No word lists can be found for the language "en_US".)

This is likely due to ispell-aspell-data-dir and/or ispell-aspell-data-dir being nil, as can be (partially) seen given your config.

When I set ispell-change-dictionary to english and then try to re-enable > flyspell mode, flyspell throws this error message instead...

Calling (ispell-change-dictionary "english") sets up an ispell environment, which I assume ends up finding and using the path /nix/store/my1hch4x12i5n1ffhlwpb6bpsiajbv3j-aspell-0.60.6.1/lib/aspell/.

Since you've set the dictionary to "english", Emacs aspell will look that up in ispell-dictionary-alist and apply the given rules/options. In your case it ends up looking for a dictionary named "english" ­which does not exist.

In my ispell-dictionary-alist I have the following entry (not explicitly added, which is another interesting point but...):

("english" "[[:alpha:]]" "[^[:alpha:]]" "'" t ("-d" "en") nil utf-8)

Notice the ("-d" "en") part. This instructs aspell to use the dictionary named en when using a dictionary named "english". Adding this should fix things when the dictionary is set to "english":

(add-to-list 'ispell-dictionary-alist
             '("english" "[[:alpha:]]" "[^[:alpha:]]" "'" t ("-d" "en") nil utf-8))

Note that, from the ispell emacs docs utf-8 will be:

used to encode text sent to the ispell subprocess when the language uses non-ASCII characters.

Which may not be what you want.

Since setting the above relies on the implicit config done by (ispell-change-dictionary), you may want to try it before/after and with/without explicitly setting the dictionary to "english":

(setq ispell-aspell-data-dir "/nix/store/my1hch4x12i5n1ffhlwpb6bpsiajbv3j-aspell-0.60.6.1/lib/aspell/")
(setq ispell-aspell-dict-dir ispell-aspell-data-dir)

The downside to this is that it's not portable across machines.

  • I've now tried setting my ispell-aspell-data-dir and ispell-aspell-dict-dir to the appropriate location for nix's aspell package and for nix's aspell-dict-en package, and for both I tried adding adding that entry to my ispell-dictionary-alist and changing the dictionary to english, but I still get the same errors. Please let me know if you have any other ideas, but regardless thank you so much for taking the time to help me! – user110524 Jan 20 '18 at 23:57
  • Does it work when you run M-x ispell on a buffer? If not, let's try this: 1 start emacs via emacs -Q 2 set ispell-aspell-data-dir to the nix aspell dict path 3 set ispell-dict to "en_US" 4 from the *scratch* buffer run M-x ispell. What happens then? Also, what's the output of aspell config data-dir? – sshaw Jan 21 '18 at 16:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.