platformio/platformio-core

Library Name Collision: External Registry Libraries Override Built-in Framework Libraries

Open

#5.261 geöffnet am 20. Sept. 2025

Auf GitHub ansehen
 (2 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Python (791 Forks)batch import
LDFhelp wanted

Repository-Metriken

Stars
 (7.329 Stars)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

Problem

When using lib_ldf_mode = off and explicitly declaring dependencies, PlatformIO resolves library names to external registry libraries instead of built-in framework libraries, even when the intent is to use the framework's native implementation.

Example

User specifies ESP32's built-in Preferences library:

{
  "dependencies": {
    "Preferences": "*"
  }
}

PlatformIO incorrectly resolves this to vshymanskyy/Preferences from the registry instead of the native ESP32 framework library.

Impact

  • Project Breakage: Working projects can suddenly break when someone registers a library with a conflicting name (e.g., Wire, SPI, Preferences)
  • Unpredictable Builds: Library resolution depends on external registry state rather than framework specifications

Workaround

Specify exact versions that don't exist in external registry:

{
  "dependencies": {
    "Preferences": "3.3.1"
  }
}

This is fragile and not a long-term solution: it will break if someone registers a library with the same name and with that version

Possible Solutions

  1. Explicit Framework Syntax: Add syntax to explicitly reference framework libraries:

    • "framework:Preferences": "*"
    • "builtin:Preferences": "*"
  2. Priority-based Resolution: Built-in framework libraries should take precedence over registry libraries when names conflict

References

Original discussion: https://community.platformio.org/t/how-to-explicitly-include-a-built-in-framework-library/52570

----------- EDIT: it seems the problem only occurs in a library.json file ("dependencies" clause), not in platformio.ini ("lib_deps" clause).

Contributor Guide