Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about executable #3

Closed
Shatur opened this issue Oct 1, 2020 · 26 comments
Closed

Question about executable #3

Shatur opened this issue Oct 1, 2020 · 26 comments

Comments

@Shatur
Copy link
Contributor

Shatur commented Oct 1, 2020

I use ArchLinux and have this package available in the repository. I tried to specify let g:langtool_cmd = '/usr/bin/languagetool, but this launches the UI on :LangTool. Am I doing something wrong? I use Asyncrun with Make configuration from the Readme.
I also tried to set let g:langtool_jar = /usr/share/java/languagetool/languagetool-commandline.jar but it crashes:

Error: Unable to initialize main class org.languagetool.commandline.Main
Caused by: java.lang.NoClassDefFoundError: org/languagetool/rules/Rule

(probably because it installed systen-wide?)

Works as expected when I downloaded it manually and set the path to the languagetool-commandline.jar.

@Konfekt
Copy link
Owner

Konfekt commented Oct 2, 2020

I tried to specify let g:langtool_cmd = '/usr/bin/languagetool, but this launches the UI on :LangTool.

Looking at the source adding --http could help.

(probably because it installed systen-wide?)

Yes, by a look at the source appending --classpath followed by all the jar files in /usr/share/java/languagetool/ could fix this; however, this plug-in does not yet permit this. Is it necessary?

@Konfekt
Copy link
Owner

Konfekt commented Oct 2, 2020

Hmm, I wonder why the GUI is launched. Looking at

https://github.com/archlinux/svntogit-community/blob/9b4884d4d6e48ca5578e42468ea9c3024538d803/trunk/languagetool.sh#L13

if a file argument is added, then the command-line jar is launched instead of the GUI. Therefore :Make should indeed launch the command-line jar defined by

command! -bang -nargs=* -complete=file Make AsyncRun<bang> -auto=make -program=make -strip <args>

Check by :comp langtool | make %.

@Shatur
Copy link
Contributor Author

Shatur commented Oct 2, 2020

Looking at the source adding --http could help.

I tried the following:

let g:langtool_cmd = '/usr/bin/languagetool'
let g:langtool_parameters = '--http'

But got an error:

|| WARNING: unknown option: --language
|| WARNING: unknown option: en
|| WARNING: unknown option: README.md
|| 2020-10-02 07:15:57 +0000 WARNING: running in HTTP mode, consider running LanguageTool behind a reverse proxy that takes care of encryption (HTTPS)
|| 2020-10-02 07:15:58 +0000 Setting up thread pool with 10 threads
|| 2020-10-02 07:15:58 +0000 Starting LanguageTool 5.1 (build date: 2020-09-25 13:26, a0b1257) server on http://localhost:8081...
|| 2020-10-02 07:15:58 +0000 Server started

Yes, by a look at the source appending --classpath followed by all the jar files in /usr/share/java/languagetool/ could fix this; however, this plug-in does not yet permit this. Is it necessary?

Do you meant like this?

java -jar /usr/share/java/languagetool/languagetool-commandline.jar --classpath
Error: Unable to initialize main class org.languagetool.commandline.Main
Caused by: java.lang.NoClassDefFoundError: org/languagetool/rules/Rule

Check by :comp langtool | make %.

Got the following:

изображение

@Shatur
Copy link
Contributor Author

Shatur commented Oct 2, 2020

Got the following:

Sorry, forgot to remove --http. Yes, with plain make it works.

@Konfekt
Copy link
Owner

Konfekt commented Oct 2, 2020

Yes, with plain make it works.

Are you sure your :Make command definition ends in <args> as below? This final argument used to be missing (this oversight fixed recently).

command! -bang -nargs=* -complete=file Make AsyncRun<bang> -auto=make -program=make -strip <args>

@Shatur
Copy link
Contributor Author

Shatur commented Oct 2, 2020

Yes, I have this argument:
изображение
But my theme highlights -strip as red. Is it okay?
Also I use latest Neovim nightly.

@Konfekt
Copy link
Owner

Konfekt commented Oct 2, 2020

Do you meant like this?
java -jar /usr/share/java/languagetool/languagetool-commandline.jar --classpath
Error: Unable to initialize main class org.languagetool.commandline.Main
Caused by: java.lang.NoClassDefFoundError: org/languagetool/rules/Rule

I meant like

java -jar /usr/share/java/languagetool/languagetool-commandline.jar --classpath /usr/share/java/languagetool/*.jar

where /usr/share/java/languagetool/*.jar is to be replaced by the list of all jar files in /usr/share/java/languagetool/ concatenated by :; this is what

CP=/usr/share/languagetool
for name in /usr/share/java/languagetool/*.jar ; do
  CP=$CP:$name
done

at https://github.com/archlinux/svntogit-community/blob/9b4884d4d6e48ca5578e42468ea9c3024538d803/trunk/languagetool.sh#L34 produces.

@Konfekt
Copy link
Owner

Konfekt commented Oct 2, 2020

Is it okay?

Yes, that's okay as it is also happening here and working fine. It can be safely omitted anyway.

@Konfekt
Copy link
Owner

Konfekt commented Oct 2, 2020

Yes, I have this argument.

That's strange. And :comp langtool | Make % launches the GUI?

@Shatur
Copy link
Contributor Author

Shatur commented Oct 2, 2020

Oh, I'm very sorry. Probably at my first launch I really forgot to change Make. Yes, :comp langtool | Make % works. The command :LangTool works too, but prints the following error:

|| Error detected while processing function
|| langtool#langtool[19]
|| <SNR>142_lang[10]
|| Language 'en' not supported by LanguageTool!

java -jar /usr/share/java/languagetool/languagetool-commandline.jar --classpath /usr/share/java/languagetool/*.jar

Tried it (just in console), still have the same error:

Error: Unable to initialize main class org.languagetool.commandline.Main
Caused by: java.lang.NoClassDefFoundError: org/languagetool/JLanguageTool

@Konfekt
Copy link
Owner

Konfekt commented Oct 2, 2020

java -jar /usr/share/java/languagetool/languagetool-commandline.jar --classpath /usr/share/java/languagetool/*.jar
Tried it (just in console), still have the same error:

/usr/share/java/languagetool/*.jar is to be replaced by the output of ls /usr/share/java/languagetool/*.jar where all the lines are concatenated into a single line by :, for example /usr/share/java/languagetool/1.jar:/usr/share/java/languagetool/2.jar if the output lists the file names1.jar and 2.jar.

@Shatur
Copy link
Contributor Author

Shatur commented Oct 2, 2020

where all the lines are concatenated into a single line by :

I tried the following:

java -jar /usr/share/java/languagetool/languagetool-commandline.jar --classpath /usr/share/java/languagetool/aho-corasick-double-array-trie.jar:/usr/share/java/languagetool/animal-sniffer-annotations.jar:/usr/share/java/languagetool/annotations.jar:/usr/share/java/languagetool/bridj.jar:/usr/share/java/languagetool/catalan-pos-dict.jar:/usr/share/java/languagetool/checker-qual.jar:/usr/share/java/languagetool/cjftransform.jar:/usr/share/java/languagetool/commons-cli.jar:/usr/share/java/languagetool/commons-codec.jar:/usr/share/java/languagetool/commons-collections4.jar:/usr/share/java/languagetool/commons-csv.jar:/usr/share/java/languagetool/commons-io.jar:/usr/share/java/languagetool/commons-lang3.jar:/usr/share/java/languagetool/commons-logging.jar:/usr/share/java/languagetool/commons-pool2.jar:/usr/share/java/languagetool/commons-text.jar:/usr/share/java/languagetool/dx.jar:/usr/share/java/languagetool/error_prone_annotations.jar:/usr/share/java/languagetool/failureaccess.jar:/usr/share/java/languagetool/FastInfoset.jar:/usr/share/java/languagetool/french-pos-dict.jar:/usr/share/java/languagetool/german-pos-dict.jar:/usr/share/java/languagetool/grpc-api.jar:/usr/share/java/languagetool/grpc-context.jar:/usr/share/java/languagetool/grpc-core.jar:/usr/share/java/languagetool/grpc-netty-shaded.jar:/usr/share/java/languagetool/grpc-protobuf-lite.jar:/usr/share/java/languagetool/grpc-protobuf.jar:/usr/share/java/languagetool/grpc-stub.jar:/usr/share/java/languagetool/gson.jar:/usr/share/java/languagetool/guava.jar:/usr/share/java/languagetool/hamcrest-core.jar:/usr/share/java/languagetool/hanlp.jar:/usr/share/java/languagetool/hppc.jar:/usr/share/java/languagetool/hunspell.jar:/usr/share/java/languagetool/icu4j.jar:/usr/share/java/languagetool/indriya.jar:/usr/share/java/languagetool/istack-commons-runtime.jar:/usr/share/java/languagetool/j2objc-annotations.jar:/usr/share/java/languagetool/jackson-annotations.jar:/usr/share/java/languagetool/jackson-core.jar:/usr/share/java/languagetool/jackson-databind.jar:/usr/share/java/languagetool/java-jwt.jar:/usr/share/java/languagetool/javax.activation-api.jar:/usr/share/java/languagetool/javax.annotation-api.jar:/usr/share/java/languagetool/jaxb-api.jar:/usr/share/java/languagetool/jaxb-core.jar:/usr/share/java/languagetool/jaxb-runtime.jar:/usr/share/java/languagetool/jcommander.jar:/usr/share/java/languagetool/jsonic.jar:/usr/share/java/languagetool/jsr305.jar:/usr/share/java/languagetool/junit.jar:/usr/share/java/languagetool/jwordsplitter.jar:/usr/share/java/languagetool/language-detector.jar:/usr/share/java/languagetool/languagetool-commandline.jar:/usr/share/java/languagetool/languagetool-core-tests.jar:/usr/share/java/languagetool/languagetool-core.jar:/usr/share/java/languagetool/languagetool-ga-dicts.jar:/usr/share/java/languagetool/languagetool-gui-commons.jar:/usr/share/java/languagetool/languagetool-server.jar:/usr/share/java/languagetool/languagetool-tools.jar:/usr/share/java/languagetool/languagetool.jar:/usr/share/java/languagetool/listenablefuture.jar:/usr/share/java/languagetool/logback-classic.jar:/usr/share/java/languagetool/logback-core.jar:/usr/share/java/languagetool/lucene-backward-codecs.jar:/usr/share/java/languagetool/lucene-core.jar:/usr/share/java/languagetool/lucene-gosen-ipadic.jar:/usr/share/java/languagetool/mariadb-java-client.jar:/usr/share/java/languagetool/morfologik-fsa-builders.jar:/usr/share/java/languagetool/morfologik-fsa.jar:/usr/share/java/languagetool/morfologik-speller.jar:/usr/share/java/languagetool/morfologik-stemming.jar:/usr/share/java/languagetool/morfologik-tools.jar:/usr/share/java/languagetool/morfologik-ukrainian-lt.jar:/usr/share/java/languagetool/morphology-el.jar:/usr/share/java/languagetool/mybatis.jar:/usr/share/java/languagetool/opennlp-chunk-models.jar:/usr/share/java/languagetool/opennlp-postag-models.jar:/usr/share/java/languagetool/opennlp-tokenize-models.jar:/usr/share/java/languagetool/opennlp-tools.jar:/usr/share/java/languagetool/openregex.jar:/usr/share/java/languagetool/perfmark-api.jar:/usr/share/java/languagetool/proto-google-common-protos.jar:/usr/share/java/languagetool/protobuf-java.jar:/usr/share/java/languagetool/segment.jar:/usr/share/java/languagetool/simpleclient.jar:/usr/share/java/languagetool/simpleclient_common.jar:/usr/share/java/languagetool/simpleclient_guava.jar:/usr/share/java/languagetool/simpleclient_hotspot.jar:/usr/share/java/languagetool/simpleclient_httpserver.jar:/usr/share/java/languagetool/slf4j-api.jar:/usr/share/java/languagetool/spanish-pos-dict.jar:/usr/share/java/languagetool/stax-ex.jar:/usr/share/java/languagetool/trove4j.jar:/usr/share/java/languagetool/txw2.jar:/usr/share/java/languagetool/unit-api.jar:/usr/share/java/languagetool/uom-lib-common.jar

Still the same error :(

@Konfekt
Copy link
Owner

Konfekt commented Oct 2, 2020

The command :LangTool works too, but prints the following error:
|| Error detected while processing function
|| langtool#langtool[19]
|| 142_lang[10]
|| Language 'en' not supported by LanguageTool!

Yes, indeed. The problem is that the languagetool executable launches the GUI if no file path is passed; thus --list to list the available languages does not give any output.

As a workaround, how about creating an empty dummy file, say ~/empty.txt and set

let g:langtool_cmd = '/usr/bin/languagetool ~/empty.txt'

@Konfekt
Copy link
Owner

Konfekt commented Oct 2, 2020

Still the same error :(

Try appending org.languagetool.commandline.Main at the very end (after all the jar files).

@Shatur
Copy link
Contributor Author

Shatur commented Oct 2, 2020

Yes, indeed. The problem is that the languagetool executable launches the GUI if no file path is passed

No, no, sorry if I was unclear. It started the GUI when I had the wrong :Make definition with Asyncrun. I fixed it, now it work, just prints such errors. Is it okay?

Try appending org.languagetool.commandline.Main at the very end (after all the jar files).

Still the same :(

@Konfekt
Copy link
Owner

Konfekt commented Oct 2, 2020

Is it okay?

No, this is not good, but not fatal and to be expected. Could you try the suggested workaround

let g:langtool_cmd = '/usr/bin/languagetool ~/empty.txt'

@Konfekt
Copy link
Owner

Konfekt commented Oct 2, 2020

Still the same :(

I do not know why, but in any case using let g:langtool_cmd = '/usr/bin/languagetool seems the more sensible way to go and we can focus on resolving

The command :LangTool works too, but prints the following error:
|| Error detected while processing function
|| langtool#langtool[19]
|| 142_lang[10]
|| Language 'en' not supported by LanguageTool!

@Shatur
Copy link
Contributor Author

Shatur commented Oct 2, 2020

No, this is not good, but not fatal and to be expected. Could you try the suggested workaround

Tried, have the following:

|| Error detected while processing
pack/plugins/start/vim-langtool/compiler/langtool.vim|16| 
|| To use the LanguageTool compiler, please set either g:langtool_cmd to the path of an executable that starts LanguageTool in command-line, or set g:langtool_jar to the path of languagetool-commandline.jar!

I do not know why, but in any case using let g:langtool_cmd = '/usr/bin/languagetool seems the more sensible way to go and we can focus on resolving

Okay :)

@Konfekt
Copy link
Owner

Konfekt commented Oct 2, 2020

Oh, try instead keeping g:langtool_cmd as is, but set let g:langtool_parameters = '~/empty.txt'.

@Konfekt
Copy link
Owner

Konfekt commented Oct 2, 2020

Or better let g:langtool_parameters = '--http'.

@Konfekt
Copy link
Owner

Konfekt commented Oct 2, 2020

For reference, I asked at https://bugs.archlinux.org/task/68079 about an option to run the command-line version of languagetool by the Archlinux package.

@Shatur
Copy link
Contributor Author

Shatur commented Oct 2, 2020

Oh, try instead keeping g:langtool_cmd as is, but set let g:langtool_parameters = '~/empty.txt'.

|| Unknown parameter: /home/gena/empty.txt
|| Usage: java -jar languagetool-commandline.jar [OPTION]... FILE
||  FILE                      plain text file to be checked
||  Available options:
||   -r, --recursive          work recursively on directory, not on a single file
||   -c, --encoding ENC       character set of the input text, e.g. utf-8 or latin1
||   -b                       assume that a single line break marks the end of a paragraph
||   -l, --language LANG      the language code of the text, e.g. en for English, en-GB for British English
||   --list                   print all available languages and exit
||   -adl, --autoDetect       auto-detect the language of the input text - note this will not detect
||                            variants like 'English (US)', so you will not get spell checking for
||                            languages with variants
||   -m, --mothertongue LANG  the language code of your first language, used to activate false-friend checking
||   -d, --disable RULES      a comma-separated list of rule ids to be disabled (use no spaces between ids)
||   -e, --enable RULES       a comma-separated list of rule ids to be enabled (use no spaces between ids)
||   -eo, --enabledonly       disable all rules except those enabled explicitly in -e
||   --enablecategories CAT   a comma-separated list of category ids to be enabled (use no spaces between ids)
||   --disablecategories CAT  a comma-separated list of category ids to be disabled (use no spaces between ids)
||   -t, --taggeronly         don't check, but only print text analysis (sentences, part-of-speech tags)
||   -u, --list-unknown       also print a summary of words from the input that LanguageTool doesn't know
||   -b2, --bitext            check bilingual texts with a tab-separated input file,
||                            see http://languagetool.wikidot.com/checking-translations-bilingual-texts
||   --api                    print results as XML (deprecated, please use --json or the JSON API in server mode)
||   --json                   print results as JSON
||   -p, --profile            print performance measurements
||   -v, --verbose            print text analysis (sentences, part-of-speech tags) to STDERR
||   --version                print LanguageTool version number and exit
||   -a, --apply              automatically apply suggestions if available, printing result to STDOUT
||                            NOTE: only use with very robust rules, as this will otherwise introduce new errors
||   --rulefile FILE          use an additional grammar file; if the filename contains a known language code,
||                            it is used in addition of standard rules
||   --remoterules FILE       configure rules depending on external services via a JSON file (optional)
||   --falsefriends FILE      use external false friend file to be used along with the built-in rules
||   --bitextrules  FILE      use external bitext XML rule file (useful only in bitext mode)
||   --languagemodel DIR      a directory with e.g. 'en' sub directory (i.e. a language code) that contains
||                            '1grams'...'3grams' sub directories with Lucene indexes with
||                            ngram occurrence counts; activates the confusion rule if supported;
||                            see http://wiki.languagetool.org/finding-errors-using-n-gram-data
||   --word2vecmodel DIR      a directory with e.g. 'en' sub directory (i.e. a language code) that contains
||                            final_embeddings.txt and dictionary.txt; activates neural network based rules
||   --neuralnetworkmodel DIR a base directory for various saved neural network models (deprecated)
||   --fasttextmodel FILE     fasttext language detection model (optional), see https://fasttext.cc/docs/en/language-identification.html
||   --fasttextbinary FILE    fasttext executable (optional), see https://fasttext.cc/docs/en/support.html
||   --xmlfilter              remove XML/HTML elements from input before checking (deprecated)
||   --line-by-line           work on file line by line (for development, e.g. inside an IDE)
||   --enable-temp-off        enable all temp_off rules (for testing and development)
||   --level level            enable the given level (currently only 'PICKY')
|| [Finished in 1 seconds with code 1]

Or better let g:langtool_parameters = '--http'.

|| WARNING: unknown option: --language
|| WARNING: unknown option: en
|| WARNING: unknown option: plugin/langtool.vim
|| 2020-10-02 19:31:28 +0000 WARNING: running in HTTP mode, consider running LanguageTool behind a reverse proxy that takes care of encryption (HTTPS)
|| 2020-10-02 19:31:29 +0000 Setting up thread pool with 10 threads
|| 2020-10-02 19:31:29 +0000 Starting LanguageTool 5.1 (build date: 2020-09-25 13:26, a0b1257) server on http://localhost:8081...
|| 2020-10-02 19:31:29 +0000 Server started

Steps to reproduce:
Run languagetool --list.
Expected: the list of all available languages on the command-line.
Instead, the GUI is openend.

In my case on languagetool --list it just crashes:

Exception in thread "main" java.lang.UnsatisfiedLinkError: Can't load library: /usr/lib/jvm/java-14-openjdk/lib/libawt_xawt.so
        at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2640)
        at java.base/java.lang.Runtime.load0(Runtime.java:745)
        at java.base/java.lang.System.load(System.java:1871)
        at java.base/java.lang.ClassLoader$NativeLibrary.load0(Native Method)
        at java.base/java.lang.ClassLoader$NativeLibrary.load(ClassLoader.java:2452)
        at java.base/java.lang.ClassLoader$NativeLibrary.loadLibrary(ClassLoader.java:2508)
        at java.base/java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2704)
        at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2658)
        at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:807)
        at java.base/java.lang.System.loadLibrary(System.java:1907)
        at java.desktop/java.awt.Toolkit$2.run(Toolkit.java:1380)
        at java.desktop/java.awt.Toolkit$2.run(Toolkit.java:1378)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:312)
        at java.desktop/java.awt.Toolkit.loadLibraries(Toolkit.java:1377)
        at java.desktop/java.awt.Toolkit.<clinit>(Toolkit.java:1410)
        at java.desktop/java.awt.Component.<clinit>(Component.java:622)
        at org.languagetool.gui.Main.<init>(Main.java:193)
        at org.languagetool.gui.Main.main(Main.java:1178)

Konfekt added a commit that referenced this issue Oct 3, 2020
@Konfekt
Copy link
Owner

Konfekt commented Oct 3, 2020

on languagetool --list it just crashes:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Can't load library: /usr/lib/jvm/java-14-openjdk/lib/libawt_xawt.so

Okay, so that should be taken care of to avoid

|| 142_lang[10]
|| Language 'en' not supported by LanguageTool!

In the meanwhile, the error message was reduced in severity to a notification message and the spellcheck language tried anyway.

@Shatur
Copy link
Contributor Author

Shatur commented Oct 3, 2020

Tried new version, now I do not have an error. If I use let g:langtool_parameters = '--http' it prints the following:

|| WARNING: unknown option: --language
|| WARNING: unknown option: en
|| WARNING: unknown option: plugin/langtool.vim
|| 2020-10-03 08:33:55 +0000 WARNING: running in HTTP mode, consider running LanguageTool behind a reverse proxy that takes care of encryption (HTTPS)
|| 2020-10-03 08:33:56 +0000 Setting up thread pool with 10 threads
|| 2020-10-03 08:33:56 +0000 Starting LanguageTool 5.1 (build date: 2020-09-25 13:26, a0b1257) server on http://localhost:8081...
|| 2020-10-03 08:33:56 +0000 Server started

Without --http it just works as expected. Thank you!

@Shatur Shatur closed this as completed Oct 3, 2020
@Shatur
Copy link
Contributor Author

Shatur commented Oct 5, 2020

Steps to reproduce:
Run languagetool --list.
Expected: the list of all available languages on the command-line.
Instead, the GUI is openend.

In my case on languagetool --list it just crashes

I figured out that I need to install the jre-openjdk package to fix the crash. And yes, after that the GUI starts up :(

@Konfekt
Copy link
Owner

Konfekt commented Oct 5, 2020

Yes, so indeed the shell script

https://github.com/archlinux/svntogit-community/blob/9b4884d4d6e48ca5578e42468ea9c3024538d803/trunk/languagetool.sh#L34

is too simplistic; at least an option to start the command-line version should be added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants