languagetool-org/languagetool · error

basePath does not exist:

Error message

basePath does not exist: 

What it means

UselessExampleFinder.run() hard-codes basePath to /lt/git/languagetool/languagetool-language-modules and throws if that directory does not exist. Like RuleSimplifier, it needs the per-language grammar.xml files under that directory to analyze rule examples, and fails fast when the path is missing.

Source

Thrown at languagetool-dev/src/main/java/org/languagetool/dev/archive/UselessExampleFinder.java:56

import java.util.regex.Pattern;
import java.util.stream.Collectors;

/**
 * Finds and removes "useless" examples sentences. "Useless" are sentences
 * of type="correct" that are already covered by an incorrect counterpart
 * with a correction that, when applied, leads to the correct sentence.
 * NOTE: this is an ugly hack, it might miss sentences or even remove ones
 * that should not be removed.
 */
final class UselessExampleFinder {

  private int uselessExampleCount;
  private int removedLinesCount;

  private void run(Language lang) throws IOException {
    File basePath = new File("/lt/git/languagetool/languagetool-language-modules");
    if (!basePath.exists()) {
      throw new RuntimeException("basePath does not exist: " + basePath);
    }
    String langCode = lang.getShortCode();
    File xml = new File(basePath, "/" + langCode + "/src/main/resources/org/languagetool/rules/" + langCode + "/grammar.xml");
    List<String> xmlLines = IOUtils.readLines(new FileReader(xml));
    JLanguageTool tool = new JLanguageTool(lang);
    for (Rule rule : tool.getAllActiveRules()) {
      if (!(rule instanceof PatternRule)) {
        continue;
      }
      List<CorrectExample> correctExamples = rule.getCorrectExamples();
      List<IncorrectExample> incorrectExamples = rule.getIncorrectExamples();
      for (IncorrectExample incorrectExample : incorrectExamples) {
        checkCorrections(rule, correctExamples, incorrectExample, xmlLines);
      }
    }
    System.err.println("Useless examples: " + uselessExampleCount);
    System.err.println("Removed lines: " + removedLinesCount);
    for (String xmlLine : xmlLines) {

View on GitHub (pinned to 2e990059ce)

Solutions

  1. Edit UselessExampleFinder.java to point basePath at your actual languagetool-language-modules location.
  2. Create the expected path via symlink: mkdir -p /lt/git && ln -s $(pwd) /lt/git/languagetool.
  3. Refactor to take the base path as a CLI argument or system property instead of a hard-coded constant.
  4. Confirm each language subdirectory contains grammar.xml at src/main/resources/org/languagetool/rules/<code>/grammar.xml.

Example fix

// before
File basePath = new File("/lt/git/languagetool/languagetool-language-modules");
// after
File basePath = new File(System.getProperty("lt.modules", "./languagetool-language-modules"));
if (!basePath.exists()) {
  throw new RuntimeException("basePath does not exist: " + basePath);
}
Defensive patterns

Strategy: validation

Validate before calling

File basePath = new File(System.getProperty("lt.modules", "./languagetool-language-modules"));
if (!new File(basePath, lang.getShortCode() + "/src/main/resources/org/languagetool/rules").isDirectory()) {
  throw new IllegalArgumentException("grammar.xml not found for " + lang + " under " + basePath);
}

Try / catch

try {
  finder.run(language);
} catch (RuntimeException e) {
  if (e.getMessage() != null && e.getMessage().startsWith("basePath does not exist")) {
    System.err.println("Set -Dlt.modules to your languagetool-language-modules checkout");
  }
}

Prevention

When it happens

Trigger: Running UselessExampleFinder in any environment where /lt/git/languagetool/languagetool-language-modules is absent — different machine, CI, Docker, or a repo layout where the language modules directory is elsewhere.

Common situations: Fresh clone of the repository without the maintainer's directory layout; moved/renamed modules directory; running from an archive download rather than the git workspace the path assumes.

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/368a7d426a8c2206. Report an issue: GitHub.