languagetool-org/languagetool · error · RuntimeException

Fasttext model path not valid (file doesn't exist or is a di

Error message

Fasttext model path not valid (file doesn't exist or is a directory): 

What it means

setFasttextPaths configures the fasttext model used for language detection. A RuntimeException is thrown when the model path does not exist or is a directory — the model must be an existing regular file (typically lid.176.bin).

Source

Thrown at languagetool-server/src/main/java/org/languagetool/server/HTTPServerConfig.java:569

        JLanguageTool lt = new JLanguageTool(lang);
        lt.check("test");
      }
    }
  }

  public void setLanguageModelDirectory(String langModelDir) {
    SuggestionsOrdererConfig.setNgramsPath(langModelDir);
    languageModelDir = new File(langModelDir);
    if (!languageModelDir.exists() || !languageModelDir.isDirectory()) {
      throw new RuntimeException("LanguageModel directory not found or is not a directory: " + languageModelDir);
    }
  }

  void setFasttextPaths(String fasttextModelPath, String fasttextBinaryPath) {
    fasttextModel = new File(fasttextModelPath);
    fasttextBinary = new File(fasttextBinaryPath);
    if (!fasttextModel.exists() || fasttextModel.isDirectory()) {
      throw new RuntimeException("Fasttext model path not valid (file doesn't exist or is a directory): " + fasttextModelPath);
    }
    if (!fasttextBinary.exists() || fasttextBinary.isDirectory() || !fasttextBinary.canExecute()) {
      throw new RuntimeException("Fasttext binary path not valid (file doesn't exist, is a directory or not executable): " + fasttextBinaryPath);
    }
  }

  /*
   * @param verbose if true, the text to be checked will be displayed in case of exceptions
   */
  public boolean isVerbose() {
    return verbose;
  }

  public boolean isPublicAccess() {
    return publicAccess;
  }

  public int getPort() {

View on GitHub (pinned to 2e990059ce)

Solutions

  1. Download the fasttext language-identification model (e.g. lid.176.bin) and pass its full file path
  2. Verify the file exists and is not a directory: `ls -l <modelPath>`
  3. Use an absolute path in the --fasttextModel option

Example fix

// before
--fasttextModel /opt/fasttext/models
// after
--fasttextModel /opt/fasttext/models/lid.176.bin
Defensive patterns

Strategy: validation

Validate before calling

File model = new File(fasttextModelPath);
if (!model.isFile())
  throw new IllegalStateException("fasttext model missing: " + fasttextModelPath);

Try / catch

try {
  config.setFasttextPaths(modelPath, binaryPath);
} catch (RuntimeException e) {
  LOG.error("fasttext model invalid: {}", e.getMessage());
}

Prevention

When it happens

Trigger: Calling setFasttextPaths(modelPath, binaryPath) (or the --fasttextModel server option) with a modelPath that is missing, mistyped, or points to a directory.

Common situations: fasttext model not downloaded, path pointing at the containing directory, wrong filename (e.g. lid.176.ftz vs lid.176.bin confusion), or relative path resolved against the wrong working directory.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06). Data as JSON: /api/errors/a3f714354c5c109e. Report an issue: GitHub.