platformio-core icon indicating copy to clipboard operation
platformio-core copied to clipboard

Library with `libCompatMode: strict` is not actually being strict

Open Lenart12 opened this issue 7 months ago • 1 comments

I have a problem during build of espressif32 platform where a library with libCompatMode of strict still tries to build other platforms code. I have to set lib_compat_mode in projects platformio.ini to work around this, but I would expect that libCompatMode would set strict mode for all dependencies of my library.

See here:

project/lib/esp32-common-lib/library.json

{
  "$schema": "https://raw.githubusercontent.com/platformio/platformio-core/develop/platformio/assets/schema/library.json",
  "name": "esp32-common-lib",
  "version": "1.0.0",
  "license": "private",
  "frameworks": [
    "arduino"
  ],
  "platforms": [
    "espressif32"
  ],
  "dependencies": [
    {
      "owner": "greiman",
      "name": "SdFat",
      "version": "^2.2.0"
    },
    {
      "owner": "bblanchon",
      "name": "ArduinoJson",
      "version": "^7.0.0"
    },
    {
      "owner": "Links2004",
      "name": "WebSockets",
      "version": "^2.3.6"
    },
    {
      "owner": "esp32async",
      "name": "ESPAsyncWebServer",
      "version": "^3.7.7",
      "platforms": ["espressif32"]
    }
  ],
  "build": {
    "libCompatMode": "strict"
  }
}

The problem is RPAsyncTCP, a dependency of ESPAsyncWebServer. (ESPAsyncWebServer does not have strict libCompatMode enabled)

project/platformio.ini

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
board_build.filesystem = littlefs
lib_deps = xreef/PCF8574 library@^2.3.7
; Uncomment following line to workaround this bug
; lib_compat_mode = strict

Lenart12 avatar May 29 '25 07:05 Lenart12

I had a similar problem - with the same library set - I have the following tree

  • Example app
    • Frugal-Iot # My library under development and not yet published (platform = espressif32
      • ESPAsyncWebServer
        • AsyncTCP
        • ESPAsyncTCP
        • RPAsyncTCP

ESPAsyncWebServer's library.json has

    {
      "owner": "ayushsharma82",
      "name": "RPAsyncTCP",
      "version": "^1.3.2",
      "platforms": "raspberrypi"
    }

But app tries, and fails, to build RPAsyncTCP

The result of this is that any app using my Frugal-iot, has to set lib_compat_mode = strict even though ESPAsyncWebServer has (correctly) said it only needs RPAsyncTCP for the raspberrypi

mitra42 avatar Jul 23 '25 21:07 mitra42