arduino/Arduino · error · TargetPlatformException

Error loading {0}

Error message

Error loading {0}

What it means

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.

Source

Thrown at arduino-core/src/processing/app/debug/LegacyTargetPlatform.java:85

          format(tr("Could not find boards.txt in {0}. Is it pre-1.5?"),
                 folder.getAbsolutePath()));

    // Load boards
    try {
      PreferencesMap bPrefs = new PreferencesMap(
          boardsFile);

      // Allow overriding values in boards.txt. This allows changing
      // boards.txt (e.g. to add user-specific items to a menu), without
      // having to modify boards.txt (which, when running from git,
      // prevents files being marked as changed).
      File localboardsFile = new File(folder, "boards.local.txt");
      try {
        if (localboardsFile.exists() && localboardsFile.canRead()) {
          bPrefs.load(localboardsFile);
        }
      } catch (IOException e) {
        throw new TargetPlatformException(
            format(tr("Error loading {0}"), localboardsFile.getAbsolutePath()), e);
      }
      Map<String, PreferencesMap> boardsPreferences = bPrefs.firstLevelMap();

      // Create custom menus for this platform
      PreferencesMap menus = boardsPreferences.get("menu");
      if (menus != null)
        customMenus = menus.topLevelMap();
      boardsPreferences.remove("menu");

      // Create boards
      Set<String> boardIds = boardsPreferences.keySet();
      for (String boardId : boardIds) {
        PreferencesMap prefs = boardsPreferences.get(boardId);
        TargetBoard board = new LegacyTargetBoard(boardId, prefs, this);
        boards.put(boardId, board);

        // Pick the first board as default

View on GitHub (pinned to a0df6e0e83)

Solutions

  1. Open the file path printed in the message and verify it is valid UTF-8 text with proper key=value lines
  2. Re-apply or recreate boards.local.txt (remove it to fall back to stock boards.txt)
  3. Check file permissions and that no process holds an exclusive lock on the file
  4. Update/reinstall the platform or Arduino IDE so bundled files are intact

Example fix

// before: platform construction aborts on any load IOException
// after: sanitize/validate the file before constructing
File local = new File(folder, "boards.local.txt");
if (local.exists() && !isValidPreferencesFile(local)) {
  local.delete(); // remove corrupt override, fall back to boards.txt
}
TargetPlatform tp = new LegacyTargetPlatform(folder, preferences);
Defensive patterns

Strategy: try-catch

Validate before calling

File f = new File(folder, "boards.local.txt");
if (f.exists() && f.canRead() && f.length() > 0) {
  try (Reader r = new InputStreamReader(new FileInputStream(f), StandardCharsets.UTF_8)) { /* readable probe */ }
  catch (IOException e) { f.delete(); }
}

Type guard

boolean isLoadable(File f) {
  return f != null && f.isFile() && f.canRead() && f.length() > 0;
}

Try / catch

try {
  new LegacyTargetPlatform(folder, prefs);
} catch (TargetPlatformException e) {
  logger.warn("Platform load failed: " + e.getMessage(), e.getCause());
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


AI-assisted analysis of arduino/Arduino@a0df6e0e83 (2026-09-06). Data as JSON: /api/errors/22978ca4dff87fc6. Report an issue: GitHub.