languagetool
languagetool copied to clipboard
Unsatisfied link error on M1 (ARM) mac
We're getting the following stack trace on macOS running on Apple Silicon:
java.lang.RuntimeException: Failed to initialize BridJ (java.lang.UnsatisfiedLinkError: Can't load library: /var/folders/md/k981cwwj58n0sv3v2y529xtc0000gn/T/BridJExtractedLibraries4773592580203442708/libbridj.dylib)
at org.bridj.Platform.initLibrary(Platform.java:444)
at org.bridj.Platform.<clinit>(Platform.java:228)
at org.bridj.Pointer.<clinit>(Pointer.java:208)
at org.languagetool.rules.spelling.hunspell.DumontsHunspellDictionary.<init>(DumontsHunspellDictionary.java:37)
at org.languagetool.rules.spelling.hunspell.Hunspell.getDictionary(Hunspell.java:50)
at org.languagetool.rules.spelling.hunspell.HunspellRule.init(HunspellRule.java:502)
at org.languagetool.rules.de.GermanSpellerRule.init(GermanSpellerRule.java:1447)
at org.languagetool.rules.spelling.hunspell.HunspellRule.ensureInitialized(HunspellRule.java:476)
at org.languagetool.rules.spelling.hunspell.HunspellRule.match(HunspellRule.java:156)
at org.languagetool.JLanguageTool.checkAnalyzedSentence(JLanguageTool.java:1414)
at org.languagetool.JLanguageTool.access$1500(JLanguageTool.java:75)
at org.languagetool.JLanguageTool$TextCheckCallable.getOtherRuleMatches(JLanguageTool.java:1994)
at org.languagetool.JLanguageTool$TextCheckCallable.call(JLanguageTool.java:1906)
at org.languagetool.JLanguageTool$TextCheckCallable.call(JLanguageTool.java:1877)
at org.languagetool.JLanguageTool.performCheck(JLanguageTool.java:1338)
at org.languagetool.JLanguageTool.checkInternal(JLanguageTool.java:1016)
at org.languagetool.JLanguageTool.check(JLanguageTool.java:935)
at org.languagetool.JLanguageTool.check(JLanguageTool.java:920)
at org.languagetool.JLanguageTool.check(JLanguageTool.java:910)
at org.languagetool.JLanguageTool.check(JLanguageTool.java:892)
at org.languagetool.JLanguageTool.check(JLanguageTool.java:849)
at org.languagetool.JLanguageTool.check(JLanguageTool.java:833)
at uk.co.screamingfrog.m1spellcheck.M1SpellCheck.main(M1SpellCheck.java:24)
Caused by: java.lang.UnsatisfiedLinkError: Can't load library: /var/folders/md/k981cwwj58n0sv3v2y529xtc0000gn/T/BridJExtractedLibraries4773592580203442708/libbridj.dylib
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2393)
at java.base/java.lang.Runtime.load0(Runtime.java:755)
at java.base/java.lang.System.load(System.java:1953)
at org.bridj.Platform.initLibrary(Platform.java:420)
... 22 more
Exception in thread "main" java.lang.RuntimeException: java.lang.RuntimeException: Could not check sentence (language: German (Germany)): <sentcontent>Hello, World!</sentcontent>
at org.languagetool.JLanguageTool.performCheck(JLanguageTool.java:1342)
at org.languagetool.JLanguageTool.checkInternal(JLanguageTool.java:1016)
at org.languagetool.JLanguageTool.check(JLanguageTool.java:935)
at org.languagetool.JLanguageTool.check(JLanguageTool.java:920)
at org.languagetool.JLanguageTool.check(JLanguageTool.java:910)
at org.languagetool.JLanguageTool.check(JLanguageTool.java:892)
at org.languagetool.JLanguageTool.check(JLanguageTool.java:849)
at org.languagetool.JLanguageTool.check(JLanguageTool.java:833)
at uk.co.screamingfrog.m1spellcheck.M1SpellCheck.main(M1SpellCheck.java:24)
Caused by: java.lang.RuntimeException: Could not check sentence (language: German (Germany)): <sentcontent>Hello, World!</sentcontent>
at org.languagetool.JLanguageTool$TextCheckCallable.getOtherRuleMatches(JLanguageTool.java:2037)
at org.languagetool.JLanguageTool$TextCheckCallable.call(JLanguageTool.java:1906)
at org.languagetool.JLanguageTool$TextCheckCallable.call(JLanguageTool.java:1877)
at org.languagetool.JLanguageTool.performCheck(JLanguageTool.java:1338)
... 8 more
Caused by: java.lang.RuntimeException: Could not create hunspell instance. Please note that LanguageTool supports only 64-bit platforms (Linux, Windows, Mac) and that it requires a 64-bit JVM (Java).
at org.languagetool.rules.spelling.hunspell.DumontsHunspellDictionary.<init>(DumontsHunspellDictionary.java:45)
at org.languagetool.rules.spelling.hunspell.Hunspell.getDictionary(Hunspell.java:50)
at org.languagetool.rules.spelling.hunspell.HunspellRule.init(HunspellRule.java:502)
at org.languagetool.rules.de.GermanSpellerRule.init(GermanSpellerRule.java:1447)
at org.languagetool.rules.spelling.hunspell.HunspellRule.ensureInitialized(HunspellRule.java:476)
at org.languagetool.rules.spelling.hunspell.HunspellRule.match(HunspellRule.java:156)
at org.languagetool.JLanguageTool.checkAnalyzedSentence(JLanguageTool.java:1414)
at org.languagetool.JLanguageTool.access$1500(JLanguageTool.java:75)
at org.languagetool.JLanguageTool$TextCheckCallable.getOtherRuleMatches(JLanguageTool.java:1994)
... 11 more
Caused by: java.lang.UnsatisfiedLinkError: 'int org.bridj.Platform.sizeOf_ptrdiff_t()'
at org.bridj.Platform.sizeOf_ptrdiff_t(Native Method)
at org.bridj.Platform.<clinit>(Platform.java:232)
at org.bridj.Pointer.<clinit>(Pointer.java:208)
at org.languagetool.rules.spelling.hunspell.DumontsHunspellDictionary.<init>(DumontsHunspellDictionary.java:37)
... 19 more
I've attached a simple maven project that will reproduce it here (m1spellcheck.zip), but this is the main class:
import java.io.IOException;
import java.util.Locale;
import org.languagetool.JLanguageTool;
import org.languagetool.Languages;
public class M1SpellCheck
{
public static void main(String[] args)
{
// crash with germany, not with UK
final var languageTool = new JLanguageTool(Languages.getLanguageForLocale(Locale.GERMANY));
try
{
languageTool.check("Hello, World!");
}
catch (IOException e)
{
e.printStackTrace();
}
System.out.println("Done");
}
}
I've noticed that we don't get this crash when checking US or UK locales, but we do with German and Swedish. There may be others that cause the crash, I've not done an extensive search
Related: #4543
Hey @danielnaber, I've released hunspell-java 2.0.0. It has one smaller breaking change but removes the dependency on bridj (replaced by plain JNA), upgrades to hunspell 1.7.1 and includes binaries for M1 Macs. It'd be great if you could give it a try!
This should be fixed now in master and with the latest snapshot (2022-11-26). Please re-open if there are still issues.