{"record":{"id":"306b887bc3b19c16","repo":"languagetool-org/languagetool","slug":"languagemodel-directory-not-found-or-is-not-a-dire","errorCode":null,"errorMessage":"LanguageModel directory not found or is not a directory: ","messagePattern":"LanguageModel directory not found or is not a directory: ","errorType":"console","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"languagetool-server/src/main/java/org/languagetool/server/HTTPServerConfig.java","lineNumber":561,"sourceCode":"          throw new IllegalArgumentException(\"dictionary file does not exist or is not a file: '\" + dictPath + \"'\");\n        }\n        ServerTools.print(\"Adding dynamic spell checker language \" + name + \", code: \" + code + \", dictionary: \" + dictPath);\n        Language lang = Languages.addLanguage(name, code, new File(dictPath));\n        // better fail early in case of misconfiguration, so use the language now:\n        if (!new File(lang.getCommonWordsPath()).exists()) {\n          throw new IllegalArgumentException(\"Common words path not found: '\" + lang.getCommonWordsPath() + \"'\");\n        }\n        JLanguageTool lt = new JLanguageTool(lang);\n        lt.check(\"test\");\n      }\n    }\n  }\n\n  public void setLanguageModelDirectory(String langModelDir) {\n    SuggestionsOrdererConfig.setNgramsPath(langModelDir);\n    languageModelDir = new File(langModelDir);\n    if (!languageModelDir.exists() || !languageModelDir.isDirectory()) {\n      throw new RuntimeException(\"LanguageModel directory not found or is not a directory: \" + languageModelDir);\n    }\n  }\n\n  void setFasttextPaths(String fasttextModelPath, String fasttextBinaryPath) {\n    fasttextModel = new File(fasttextModelPath);\n    fasttextBinary = new File(fasttextBinaryPath);\n    if (!fasttextModel.exists() || fasttextModel.isDirectory()) {\n      throw new RuntimeException(\"Fasttext model path not valid (file doesn't exist or is a directory): \" + fasttextModelPath);\n    }\n    if (!fasttextBinary.exists() || fasttextBinary.isDirectory() || !fasttextBinary.canExecute()) {\n      throw new RuntimeException(\"Fasttext binary path not valid (file doesn't exist, is a directory or not executable): \" + fasttextBinaryPath);\n    }\n  }\n\n  /*\n   * @param verbose if true, the text to be checked will be displayed in case of exceptions\n   */\n  public boolean isVerbose() {","sourceCodeStart":543,"sourceCodeEnd":579,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-server/src/main/java/org/languagetool/server/HTTPServerConfig.java#L543-L579","documentation":"setLanguageModelDirectory configures the n-gram LanguageModel directory used for better suggestions (e.g. for English/German). A RuntimeException is thrown when the supplied path does not exist or is a file rather than a directory.","triggerScenarios":"Calling setLanguageModelDirectory(path) (directly or via the --languageModel server option) with a path that is absent on disk or points to a regular file.","commonSituations":"Forgetting to download/extract the n-grams dataset before starting the server, pointing at the zip archive instead of the extracted directory, or a typo in the path.","solutions":["Download and unzip the n-grams data for the language and pass the extracted directory path","Verify with `ls -ld <path>` that the path exists and is a directory","Fix the --languageModel argument or config property to the correct directory"],"exampleFix":"// before\n--languageModel /opt/ngrams-en.zip\n// after\n--languageModel /opt/ngrams-en","handlingStrategy":"validation","validationCode":"File dir = new File(langModelDir);\nif (!dir.isDirectory())\n  throw new IllegalStateException(\"LanguageModel dir missing: \" + langModelDir);","typeGuard":null,"tryCatchPattern":"try {\n  config.setLanguageModelDir(modelDir);\n} catch (RuntimeException e) {\n  LOG.error(\"Bad languageModel dir: {}\", e.getMessage());\n}","preventionTips":["Download and extract n-gram data before starting the server","Point at the extracted directory, not the zip","Verify with `ls -ld` in your startup script before launch"],"tags":["configuration","filesystem","ngrams"],"backgroundTag":"directory-not-found","analyzedSha":"2e990059ce67d5e2a0f7f7ca5d31160c6709df4b","analyzedAt":"2026-09-06T09:20:17.015Z","contentChangedAt":"2026-09-06T09:20:17.015Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}