languagetool-org/languagetool · error
basePath does not exist:
Error message
basePath does not exist:
What it means
RuleSimplifier.run() hard-codes basePath to /lt/git/languagetool/languagetool-language-modules — the maintainer's private checkout path — and throws immediately if that directory does not exist. The tool cannot locate the per-language grammar.xml files it needs to analyze, so it fails fast at startup.
Source
Thrown at languagetool-dev/src/main/java/org/languagetool/dev/archive/RuleSimplifier.java:51
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Replaces the 'pattern' element in simple rules with the 'regexp' element.
* WARNING: this is a hack, the rules it produces need to be checked and modified manually!
*/
final class RuleSimplifier {
private int touchedRulesCount;
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);
int totalRules = 0;
for (Rule rule : tool.getAllActiveRules()) {
if (!(rule instanceof PatternRule)) {
continue;
}
PatternRule patternRule = (PatternRule) rule;
String id = patternRule.getFullId();
if (isSimple((PatternRule)rule)) {
System.err.println("Simplifying: " + id);
simplify(patternRule, xmlLines);
} else {
System.err.println("Can't simplify: " + id);
}View on GitHub (pinned to 2e990059ce)
Solutions
- Edit RuleSimplifier.java to point basePath at your local checkout, e.g. new File("path/to/languagetool/languagetool-language-modules") or derive it from the current directory.
- Create a symlink so the expected path exists: mkdir -p /lt/git && ln -s /path/to/your/languagetool /lt/git/languagetool.
- Better: accept the base path as a main() argument or system property instead of hard-coding it.
- Verify the directory contains the per-language subdirectories (en, de, ...) with 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 (!basePath.isDirectory()) {
throw new IllegalArgumentException("language modules dir not found: " + basePath);
} Try / catch
try {
simplifier.run(language);
} catch (RuntimeException e) {
if (e.getMessage() != null && e.getMessage().startsWith("basePath does not exist")) {
System.err.println("Configure -Dlt.modules=<path to languagetool-language-modules>");
}
} Prevention
- Never hard-code absolute maintainer paths; accept base paths via CLI args or system properties
- Check the repo layout with ls before running dev tools that read language module sources
- Use a symlink to normalize checkout locations across machines
- Fail with a message that names the expected configuration property
When it happens
Trigger: Running RuleSimplifier on any machine where /lt/git/languagetool/languagetool-language-modules does not exist — i.e. any environment other than the original developer's workspace, including fresh clones where modules live at ./languagetool-language-modules.
Common situations: Cloning the LanguageTool repo and running dev tools without the required sibling directory layout; running in CI or Docker where the repo is checked out to a different path; renaming or moving the languagetool-language-modules directory after a repository restructure.
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
- basePath does not exist:
- IOException while writing debug log line
- IOException while writing debug tags
- WrongParameterNumberException
- <dir.getAbsolutePath()> is not a directory, cannot use recur
AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06).
Data as JSON: /api/errors/1032683e7fd926db.
Report an issue: GitHub.