languagetool-org/languagetool · error

basePath does not exist:

Error message

basePath does not exist: 

What it means

ExampleSentenceCorrectionCreator.run depends on a hard-coded developer path (/lt/git/languagetool/languagetool-language-modules) that must contain the language modules it edits. It throws a RuntimeException when that directory does not exist on the current machine.

Source

Thrown at languagetool-dev/src/main/java/org/languagetool/dev/archive/ExampleSentenceCorrectionCreator.java:50

import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Ugly hack for one-time-use only: add 'correction' attributes to
 * example sentences automatically.
 */
final class ExampleSentenceCorrectionCreator {

  private int addedCorrectionsCount = 0;

  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.getAllRules()) {
      if (!(rule instanceof PatternRule)) {
        continue;
      }
      List<IncorrectExample> incorrectExamples = rule.getIncorrectExamples();
      for (IncorrectExample incorrectExample : incorrectExamples) {
        checkCorrections(rule, incorrectExample, xmlLines, tool);
      }
    }
    System.err.println("Added corrections: " + addedCorrectionsCount);
    for (String xmlLine : xmlLines) {
      System.out.println(xmlLine);
    }

View on GitHub (pinned to 2e990059ce)

Solutions

  1. Symlink or create the expected directory pointing at your actual languagetool-language-modules checkout
  2. Edit ExampleSentenceCorrectionCreator.java to accept the base path via a command-line argument or system property
  3. Run from a checkout laid out to match the expected absolute path (e.g. inside a container mounted at /lt)

Example fix

// before
File basePath = new File("/lt/git/languagetool/languagetool-language-modules");
// after
File basePath = new File(System.getProperty("lt.languageModules", "languagetool-language-modules"));
Defensive patterns

Strategy: validation

Validate before calling

File basePath = new File("/lt/git/languagetool/languagetool-language-modules");
if (!basePath.exists()) { throw new IllegalStateException("Set lt.languageModules to your checkout; missing: " + basePath); }

Try / catch

try { new ExampleSentenceCorrectionCreator().run(lang); } catch (RuntimeException e) { if (e.getMessage().startsWith("basePath does not exist")) { System.err.println("Point the script at your languagetool-language-modules checkout"); } }

Prevention

When it happens

Trigger: Running the tool on any machine where the hard-coded absolute path /lt/git/languagetool/languagetool-language-modules is absent — any machine but the original author's.

Common situations: Running the dev tool after cloning languagetool to a different location; different username/drive layout; CI environments; Windows machines.

Related errors


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