{"record":{"id":"368a7d426a8c2206","repo":"languagetool-org/languagetool","slug":"basepath-does-not-exist-368a7d","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/UselessExampleFinder.java","lineNumber":56,"sourceCode":"import java.util.regex.Pattern;\nimport java.util.stream.Collectors;\n\n/**\n * Finds and removes \"useless\" examples sentences. \"Useless\" are sentences\n * of type=\"correct\" that are already covered by an incorrect counterpart\n * with a correction that, when applied, leads to the correct sentence.\n * NOTE: this is an ugly hack, it might miss sentences or even remove ones\n * that should not be removed.\n */\nfinal class UselessExampleFinder {\n\n  private int uselessExampleCount;\n  private int removedLinesCount;\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    for (Rule rule : tool.getAllActiveRules()) {\n      if (!(rule instanceof PatternRule)) {\n        continue;\n      }\n      List<CorrectExample> correctExamples = rule.getCorrectExamples();\n      List<IncorrectExample> incorrectExamples = rule.getIncorrectExamples();\n      for (IncorrectExample incorrectExample : incorrectExamples) {\n        checkCorrections(rule, correctExamples, incorrectExample, xmlLines);\n      }\n    }\n    System.err.println(\"Useless examples: \" + uselessExampleCount);\n    System.err.println(\"Removed lines: \" + removedLinesCount);\n    for (String xmlLine : xmlLines) {","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-dev/src/main/java/org/languagetool/dev/archive/UselessExampleFinder.java#L38-L74","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Edit UselessExampleFinder.java to point basePath at your actual languagetool-language-modules location.","Create the expected path via symlink: mkdir -p /lt/git && ln -s $(pwd) /lt/git/languagetool.","Refactor to take the base path as a CLI argument or system property instead of a hard-coded constant.","Confirm each language subdirectory contains grammar.xml at 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 (!new File(basePath, lang.getShortCode() + \"/src/main/resources/org/languagetool/rules\").isDirectory()) {\n  throw new IllegalArgumentException(\"grammar.xml not found for \" + lang + \" under \" + basePath);\n}","typeGuard":null,"tryCatchPattern":"try {\n  finder.run(language);\n} catch (RuntimeException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"basePath does not exist\")) {\n    System.err.println(\"Set -Dlt.modules to your languagetool-language-modules checkout\");\n  }\n}","preventionTips":["Parameterize repository base paths instead of hard-coding /lt/git/... style maintainer paths","Check that the language module directory exists before launching batch analysis","Document required repo layout in the tool's main() usage message","Run such tools from the repository root so relative default paths work"],"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"}