Bug 496925

Summary: Sonnet does not find installed hunspell dictionaries on Nixos
Product: [Frameworks and Libraries] frameworks-sonnet Reporter: alister.hood
Component: generalAssignee: Martin Sandsmark <martin.sandsmark>
Status: RESOLVED FIXED    
Severity: normal CC: kdelibs-bugs-null
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description alister.hood 2024-12-02 10:17:32 UTC
SUMMARY

It seems that sonnet can only use hunspell dictionaries installed in certain hard-coded locations, and does not even look in $DICPATH.  This means that hunspell dictionaries installed on platforms like NixOS or Guix are not available in KDE applications, although they work fine with hunspell itself and other applications that don't use sonnet, like firefox and mousepad, at least if $DICPATH is set.

Ideally I think sonnet should use exactly the same logic to find hunspell dictionaries as the hunspell cli tool does.
It should at least use $DICPATH if that is set, anyway.

STEPS TO REPRODUCE
1.  Install NixOS, including KDE, and a hunspell dictionary e.g.:

  environment.systemPackages = with pkgs; [
    hunspellDicts.en_GB-ise
    kdePackages.sonnet
    ];
  # allow Firefox etc to see our system dictionary
  environment.sessionVariables.DICPATH = "${pkgs.hunspellDicts.en_GB-ise}/share/hunspell";
  services.desktopManager.plasma6.enable = true;
  services.displayManager.defaultSession = "plasmax11";
  services.xserver.enable = true;

2. try calligrawords or some other KDE app and see spellchecking does not work.  Look in the settings and see KDE thinks there are no available dictionaries.

OBSERVED RESULT
Sonnet cannot find any dictionaries, so there is no spellchecking in any KDE apps.
Firefox, hunspell (cli tool), mousepad etc recognise the dictionary and spellchecking works.

EXPECTED RESULT
Sonnet should see the dictionary, and spellchecking should work in KDE apps.

SOFTWARE/OS VERSIONS
Operating System: NixOS 24.11
KDE Plasma Version: 6.2.3
KDE Frameworks Version: 6.8.0
Qt Version: 6.8.0
Kernel Version: 6.6.63 (64-bit)
Graphics Platform: X11

ADDITIONAL INFORMATION
This ticket at NixOS https://github.com/NixOS/nixpkgs/issues/14430 has a checkbox next to the action "fix sonnet: complain upsteam about them not obeying XDG Standard", but I couldn't find a relevant KDE ticket or anything, so I'm not sure how they "complained", and given how old the NixOS ticket is, it seemed worth filing this here.
Note there is also mention there of $XDG_DATA_DIRS being relevant for enchant and firefox; I haven't tested to check that.

Guix has a ticket at https://issues.guix.gnu.org/63934

I see years ago there used to be HUNSPELL_MAIN_DICT_PATH in the sonnet code, which I think might have allowed a custom location to be specified at build time, but that is gone now.
Comment 1 alister.hood 2025-05-30 10:20:57 UTC
OK, this must have been fixed in recent versions as it is now working on NixOS.
Thanks to whoever fixed it!