{"record":{"id":"1032683e7fd926db","repo":"languagetool-org/languagetool","slug":"basepath-does-not-exist-103268","errorCode":null,"errorMessage":"basePath does not exist: ","messagePattern":"basePath does not exist: ","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"languagetool-dev/src/main/java/org/languagetool/dev/archive/RuleSimplifier.java","lineNumber":51,"sourceCode":"import java.io.IOException;\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.List;\nimport java.util.regex.Matcher;\nimport java.util.regex.Pattern;\n\n/**\n * Replaces the 'pattern' element in simple rules with the 'regexp' element.\n * WARNING: this is a hack, the rules it produces need to be checked and modified manually!\n */\nfinal class RuleSimplifier {\n\n  private int touchedRulesCount;\n\n  private void run(Language lang) throws IOException {\n    File basePath = new File(\"/lt/git/languagetool/languagetool-language-modules\");\n    if (!basePath.exists()) {\n      throw new RuntimeException(\"basePath does not exist: \" + basePath);\n    }\n    String langCode = lang.getShortCode();\n    File xml = new File(basePath, \"/\" + langCode + \"/src/main/resources/org/languagetool/rules/\" + langCode + \"/grammar.xml\");\n    List<String> xmlLines = IOUtils.readLines(new FileReader(xml));\n    JLanguageTool tool = new JLanguageTool(lang);\n    int totalRules = 0;\n    for (Rule rule : tool.getAllActiveRules()) {\n      if (!(rule instanceof PatternRule)) {\n        continue;\n      }\n      PatternRule patternRule = (PatternRule) rule;\n      String id = patternRule.getFullId();\n      if (isSimple((PatternRule)rule)) {\n        System.err.println(\"Simplifying: \" + id);\n        simplify(patternRule, xmlLines);\n      } else {\n        System.err.println(\"Can't simplify: \" + id);\n      }","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-dev/src/main/java/org/languagetool/dev/archive/RuleSimplifier.java#L33-L69","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nFile basePath = new File(\"/lt/git/languagetool/languagetool-language-modules\");\n// after\nFile basePath = new File(System.getProperty(\"lt.modules\", \"./languagetool-language-modules\"));\nif (!basePath.exists()) {\n  throw new RuntimeException(\"basePath does not exist: \" + basePath);\n}","handlingStrategy":"validation","validationCode":"File basePath = new File(System.getProperty(\"lt.modules\", \"./languagetool-language-modules\"));\nif (!basePath.isDirectory()) {\n  throw new IllegalArgumentException(\"language modules dir not found: \" + basePath);\n}","typeGuard":null,"tryCatchPattern":"try {\n  simplifier.run(language);\n} catch (RuntimeException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"basePath does not exist\")) {\n    System.err.println(\"Configure -Dlt.modules=<path to languagetool-language-modules>\");\n  }\n}","preventionTips":["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"],"tags":["java","filesystem","hardcoded-path","dev-tooling"],"backgroundTag":"file-not-found","analyzedSha":"2e990059ce67d5e2a0f7f7ca5d31160c6709df4b","analyzedAt":"2026-09-06T09:20:17.015Z","contentChangedAt":"2026-09-06T09:20:17.015Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}