{"record":{"id":"22978ca4dff87fc6","repo":"arduino/Arduino","slug":"error-loading-0","errorCode":null,"errorMessage":"Error loading {0}","messagePattern":"Error loading (.+?)","errorType":"exception","errorClass":"TargetPlatformException","httpStatus":null,"severity":"error","filePath":"arduino-core/src/processing/app/debug/LegacyTargetPlatform.java","lineNumber":85,"sourceCode":"          format(tr(\"Could not find boards.txt in {0}. Is it pre-1.5?\"),\n                 folder.getAbsolutePath()));\n\n    // Load boards\n    try {\n      PreferencesMap bPrefs = new PreferencesMap(\n          boardsFile);\n\n      // Allow overriding values in boards.txt. This allows changing\n      // boards.txt (e.g. to add user-specific items to a menu), without\n      // having to modify boards.txt (which, when running from git,\n      // prevents files being marked as changed).\n      File localboardsFile = new File(folder, \"boards.local.txt\");\n      try {\n        if (localboardsFile.exists() && localboardsFile.canRead()) {\n          bPrefs.load(localboardsFile);\n        }\n      } catch (IOException e) {\n        throw new TargetPlatformException(\n            format(tr(\"Error loading {0}\"), localboardsFile.getAbsolutePath()), e);\n      }\n      Map<String, PreferencesMap> boardsPreferences = bPrefs.firstLevelMap();\n\n      // Create custom menus for this platform\n      PreferencesMap menus = boardsPreferences.get(\"menu\");\n      if (menus != null)\n        customMenus = menus.topLevelMap();\n      boardsPreferences.remove(\"menu\");\n\n      // Create boards\n      Set<String> boardIds = boardsPreferences.keySet();\n      for (String boardId : boardIds) {\n        PreferencesMap prefs = boardsPreferences.get(boardId);\n        TargetBoard board = new LegacyTargetBoard(boardId, prefs, this);\n        boards.put(boardId, board);\n\n        // Pick the first board as default","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/arduino/Arduino/blob/a0df6e0e83b652c72bc78b0a1376c54d6ebc3bee/arduino-core/src/processing/app/debug/LegacyTargetPlatform.java#L67-L103","documentation":"LegacyTargetPlatform throws TargetPlatformException wrapping an IOException when it cannot read boards.local.txt, the file holding local board overrides for this platform. The constructor loads the file into a PreferencesMap via load(); any I/O failure (unreadable, decode error, IO error mid-read) aborts platform construction with this message. The {0} placeholder is filled with the absolute path of the offending file.","triggerScenarios":"Constructing a LegacyTargetPlatform for a hardware folder whose boards.local.txt exists and is readable-permissioned but fails PreferencesMap.load() with an IOException (e.g. decode failure, IO error, file removed between exists() check and read).","commonSituations":"Corrupted or binary garbage boards.local.txt edited by a broken tool; the file deleted between the exists() check and load; locked files on Windows; invalid non-UTF8 encodings saved by some editors.","solutions":["Open the file path printed in the message and verify it is valid UTF-8 text with proper key=value lines","Re-apply or recreate boards.local.txt (remove it to fall back to stock boards.txt)","Check file permissions and that no process holds an exclusive lock on the file","Update/reinstall the platform or Arduino IDE so bundled files are intact"],"exampleFix":"// before: platform construction aborts on any load IOException\n// after: sanitize/validate the file before constructing\nFile local = new File(folder, \"boards.local.txt\");\nif (local.exists() && !isValidPreferencesFile(local)) {\n  local.delete(); // remove corrupt override, fall back to boards.txt\n}\nTargetPlatform tp = new LegacyTargetPlatform(folder, preferences);","handlingStrategy":"try-catch","validationCode":"File f = new File(folder, \"boards.local.txt\");\nif (f.exists() && f.canRead() && f.length() > 0) {\n  try (Reader r = new InputStreamReader(new FileInputStream(f), StandardCharsets.UTF_8)) { /* readable probe */ }\n  catch (IOException e) { f.delete(); }\n}","typeGuard":"boolean isLoadable(File f) {\n  return f != null && f.isFile() && f.canRead() && f.length() > 0;\n}","tryCatchPattern":"try {\n  new LegacyTargetPlatform(folder, prefs);\n} catch (TargetPlatformException e) {\n  logger.warn(\"Platform load failed: \" + e.getMessage(), e.getCause());\n}","preventionTips":["Keep boards.local.txt in plain UTF-8 key=value format","Avoid cloud-sync tools on hardware folders","Validate override files after manual edits","Remove stale override files after IDE upgrades"],"tags":["file-io","config-file","platform-loading","arduino"],"backgroundTag":"file-read-failed","analyzedSha":"a0df6e0e83b652c72bc78b0a1376c54d6ebc3bee","analyzedAt":"2026-09-06T10:13:38.901Z","contentChangedAt":"2026-09-06T10:13:38.901Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}