languagetool-org/languagetool · error

basePath does not exist:

Error message

basePath does not exist: 

What it means

ExampleSentencePrinter.run relies on a hard-coded developer workspace path (/home/dnaber/lt/git/languagetool/languagetool-language-modules) to locate language module XML files. It throws a RuntimeException at startup when that path does not exist on the current machine.

Source

Thrown at languagetool-dev/src/main/java/org/languagetool/dev/ExampleSentencePrinter.java:40

import org.languagetool.Language;
import org.languagetool.Languages;
import org.languagetool.rules.IncorrectExample;
import org.languagetool.rules.Rule;

import java.io.File;
import java.util.List;

/**
 * Prints the first of the incorrect examples per rule.
 */
final class ExampleSentencePrinter {

  private static final int MAX_BLOCK_SIZE = 5000;
  
  private void run(Language lang) {
    File basePath = new File("/home/dnaber/lt/git/languagetool/languagetool-language-modules");
    if (!basePath.exists()) {
      throw new RuntimeException("basePath does not exist: " + basePath);
    }
    JLanguageTool tool = new JLanguageTool(lang);
    System.out.println("<html>");
    System.out.println("<head>");
    System.out.println("  <title>LanguageTool examples sentences</title>");
    System.out.println("  <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />");
    System.out.println("</head>");
    System.out.println("<body>");
    int i = 1;
    int blockSize = 0;
    for (Rule rule : tool.getAllActiveRules()) {
      List<IncorrectExample> incorrectExamples = rule.getIncorrectExamples();
      if (incorrectExamples.size() > 0) {
        String example = incorrectExamples.get(0).getExample()
                .replace("<marker>", "<b>")
                .replace("</marker>", "</b>");
        int exampleLength = example.replace("<b>", "").replace("</b>", "").length();
        if (blockSize + exampleLength > MAX_BLOCK_SIZE) {

View on GitHub (pinned to 2e990059ce)

Solutions

  1. Create or symlink the expected directory to your actual languagetool-language-modules checkout
  2. Edit ExampleSentencePrinter.java to use a relative path or a system property/environment variable for basePath
  3. Run the script from inside a checkout that matches the expected layout

Example fix

// before
File basePath = new File("/home/dnaber/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("/home/dnaber/lt/git/languagetool/languagetool-language-modules");
if (!basePath.exists()) { throw new IllegalStateException("Set lt.languageModules to your checkout; missing: " + basePath); }

Try / catch

try { new ExampleSentencePrinter().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 ExampleSentencePrinter main from any machine where the hard-coded absolute path does not exist — i.e. almost any machine other than the original author's.

Common situations: Cloning the languagetool-dev tool and running it on a different OS, different username, or checkout located elsewhere; running it in CI.

Related errors


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