PillFall / languagetool.el

LanguageTool suggestions integrated within Emacs
GNU General Public License v3.0
98 stars 8 forks source link

Error when trying to check a region #3

Closed Nathan-Furnal closed 3 years ago

Nathan-Furnal commented 3 years ago

Hi,

I installed languagetool through pacman (archlinux), it works fine on its own. But when I try to use it in Emacs with languagetool-check, I get the following :

languagetool--invoke-command-region: LanguageTool returned with status 1

Using the server works when I start it from the command line but not from Emacs, I think this has to do with the paths not being the same when installing from a package manager rather than from the project's page.

How can I fix this?

Thanks

N.B : my config

(use-package languagetool
  :ensure t
  :defer t
  :commands (languagetool-check
         languagetool-clear-buffer
         languagetool-correct-at-point
         languagetool-correct-buffer
         languagetool-set-language)
  :config
  (setq languagetool-language-tool-jar "/usr/share/java/languagetool/languagetool-commandline.jar"
    languagetool-server-language-tool-jar "/usr/share/java/languagetool/languagetool-server.jar"
    languagetool-java-arguments '("-Dfile.encoding=UTF-8")
    languagetool-default-language "en-US"
    languagetool-java-bin "/usr/bin/java"))
PillFall commented 3 years ago

Hi,

Can you please send a screenshot of the buffer *LanguageTool Output* after you use languagetool-check. I think the problem is in the java executable or the LanguageTool binary itself. I tried to reproduce the error in Manjaro, And i can't get Java to work properly and keep getting Invalid or corrupt file error.

Nathan-Furnal commented 3 years ago

Sure !

Here you go :

 ----- LanguageTool Command:

/usr/bin/java -Dfile.encoding=UTF-8 -jar /usr/share/java/languagetool/languagetool-commandline.jar -c utf8 --json -l en-US

 ----- LanguageTool Text:

 This text is very strange weird arf 

 ----- LanguageTool Output:

Error: Unable to initialize main class org.languagetool.commandline.Main
Caused by: java.lang.NoClassDefFoundError: org/languagetool/Language
PillFall commented 3 years ago

Thanks.

I solved the issue in my Manjaro and it works normally. It was just that the file had missing the execute flag in Linux.

Now, from what I can see in your output, as I belived, there is a problem with the LanguageTool binary it self. This error was produced in ArchLinux because the package expects you to use the standalone version from LanguageTool download page. No the class files directly (ArchLinux uses and download the package class files not the executable and creates a wrapper /usr/bin/languagetool that invoke all the classes in the proper way)

I know now how to fix it and will implement that in a couple days. Meanwhile, I suggest you to download and use the standalone version from https://languagetool.org/download/

Nathan-Furnal commented 3 years ago

Thanks for the quick update =)

PillFall commented 3 years ago

Right now it didn't work, I forgot some configurations, but in the next version your config should be something like:

(use-package languagetool
  :ensure t
  :defer t
  :commands (languagetool-check
             languagetool-clear-buffer
             languagetool-correct-at-point
             languagetool-correct-buffer
             languagetool-set-language)
  :config
  (setq languagetool-language-tool-class t
        languagetool-language-tool-jar "org.languagetool.commandline.Main"
        languagetool-server-language-tool-jar "org.languagetool.server.HTTPServer"
        languagetool-java-arguments '("-Dfile.encoding=UTF-8" "-cp" "/usr/share/languagetool:/usr/share/java/languagetool/*")
        languagetool-default-language "en-US"
        languagetool-java-bin "/usr/bin/java"))
Nathan-Furnal commented 3 years ago

Thanks a ton for the quick fix!