{"record":{"id":"a33d3ac3c83b1fcc","repo":"languagetool-org/languagetool","slug":"basepath-does-not-exist-a33d3a","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/ExampleSentenceCorrectionCreator.java","lineNumber":50,"sourceCode":"import java.io.FileReader;\nimport java.io.IOException;\nimport java.util.ArrayList;\nimport java.util.List;\nimport java.util.regex.Matcher;\nimport java.util.regex.Pattern;\n\n/**\n * Ugly hack for one-time-use only: add 'correction' attributes to\n * example sentences automatically.\n */\nfinal class ExampleSentenceCorrectionCreator {\n\n  private int addedCorrectionsCount = 0;\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.getAllRules()) {\n      if (!(rule instanceof PatternRule)) {\n        continue;\n      }\n      List<IncorrectExample> incorrectExamples = rule.getIncorrectExamples();\n      for (IncorrectExample incorrectExample : incorrectExamples) {\n        checkCorrections(rule, incorrectExample, xmlLines, tool);\n      }\n    }\n    System.err.println(\"Added corrections: \" + addedCorrectionsCount);\n    for (String xmlLine : xmlLines) {\n      System.out.println(xmlLine);\n    }","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-dev/src/main/java/org/languagetool/dev/archive/ExampleSentenceCorrectionCreator.java#L32-L68","documentation":"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.","triggerScenarios":"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.","commonSituations":"Running the dev tool after cloning languagetool to a different location; different username/drive layout; CI environments; Windows machines.","solutions":["Symlink or create the expected directory pointing at your actual languagetool-language-modules checkout","Edit ExampleSentenceCorrectionCreator.java to accept the base path via a command-line argument or system property","Run from a checkout laid out to match the expected absolute path (e.g. inside a container mounted at /lt)"],"exampleFix":"// before\nFile basePath = new File(\"/lt/git/languagetool/languagetool-language-modules\");\n// after\nFile basePath = new File(System.getProperty(\"lt.languageModules\", \"languagetool-language-modules\"));","handlingStrategy":"validation","validationCode":"File basePath = new File(\"/lt/git/languagetool/languagetool-language-modules\");\nif (!basePath.exists()) { throw new IllegalStateException(\"Set lt.languageModules to your checkout; missing: \" + basePath); }","typeGuard":null,"tryCatchPattern":"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\"); } }","preventionTips":["Parameterize the base path instead of hard-coding absolute paths","Verify the expected directory before invoking the tool","Run inside an environment matching the expected layout (e.g. container mount at /lt)"],"tags":["hardcoded-path","dev-tool","file-not-found"],"backgroundTag":"directory-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"}