I'm having trouble with library dependencies for my project

I’ve been using Platformio-core for a couple years now and this is my first time using the discussion board. (Sorry – I had a bunch of helpful links but I had to reduce them to 2 because this is my first post).

I have a project I’m developing with Platformio for the ESP32 project that I am having problems with at the moment: Plant133. It uses some libraries that I developed to share between my different projects, mainly my og3 application framework. Lately I’m failing to get this and other projects to compile because of library dependency problems.

In particular, my code is using esp32async/ESPAsyncWebServer and also heman/AsyncMqttClient-esphome.

The library.json file for my og3 library is here (github) and the platform.ini file for the Plant133 project I’m trying to get to work is here on my branch where I’m trying to add a svelte-based web interface.

My code is failing to build because of conflicting dependencies. “pio pkg list” is giving me:

Libraries
├── Adafruit BusIO @ 1.17.4 (required: adafruit/Adafruit BusIO)
├── Adafruit SHTC3 Library @ 1.0.2 (required: adafruit/Adafruit SHTC3 Library)
│ └── Adafruit Unified Sensor @ 1.1.15 (required: Adafruit Unified Sensor)
├── ArduinoJson @ 7.4.2 (required: bblanchon/ArduinoJson @ ^7.0.0)
├── AsyncMqttClient-esphome @ 1.1.1 (required: heman/AsyncMqttClient-esphome @ ^1.0.0)
│ ├── AsyncTCP-esphome @ 2.1.4 (required: esphome/AsyncTCP-esphome @ ^2.0.1)
│ └── ESPAsyncTCP-esphome @ 2.0.0 (required: esphome/ESPAsyncTCP-esphome @ ^2.0.0)
├── CRC32 @ 2.0.0 (required: bakercp/CRC32)
├── ESP8266 and ESP32 OLED driver for SSD1306 displays @ 4.6.1 (required: thingpulse/ESP8266 and ESP32 OLED driver for SSD1306 displays @ ^4.2.0)
├── ESPAsyncWebServer @ 3.6.0 (required: ESP32Async/ESPAsyncWebServer @ 3.6.0)
│ ├── AsyncTCP @ 3.4.9 (required: ESP32Async/AsyncTCP @ ^3.3.2)
│ ├── AsyncTCP_RP2040W @ 1.2.0 (required: khoih-prog/AsyncTCP_RP2040W @ ^1.2.0)
│ └── ESPAsyncTCP @ 2.0.0 (required: ESP32Async/ESPAsyncTCP @ ^2.0.0)
├── og3 @ 0.3.95 (required: og3 @ ^0.3.95)
│ ├── ArduinoJson @ 7.0.4 (required: bblanchon/ArduinoJson @ ~7.0.0)
│ ├── AsyncMqttClient-esphome @ 1.0.0 (required: heman/AsyncMqttClient-esphome @ ~1.0.0)
│ │ ├── AsyncTCP-esphome @ 1.2.2 (required: esphome/AsyncTCP-esphome @ ^1.1.1)
├── og3x-oled @ 0.3.1 (required: og3x-oled @ ^0.3.1)
└── og3x-shtc3 @ 0.3.0 (required: og3x-shtc3 @ ^0.3.0)

The main source of trouble is all the different Async-TCP packages (4 of them!) that are getting pulled-in, including a version AsyncTCP_RP2040W that is meant for the “raspberrypi” platform and doesn’t build for the ESP32. This is getting pulled-in from ESPAsyncWebServer. Its library.json file codes the dependeny as

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

Is is possible that the platforms specification is not working because they supplied a string instead of a list?

Do you have any wisdom for cleaning-up dependencies so I can get my projects to build again? I’d really like to have only one version of each library compiled in, or at least to avoid pulling-in libraries for a different platform.

Then turn up the library dependency finder and compatibility checker modes up to the maximum in the library.json. See docs for library.json → build

{
   // previous stuff..
   "build": {
     "libLDFMode": "deep+",
     "libCompatMode": "strict"
  }
}

Thanks! It seemed more correct to me to modify the platform.ini file for my project than the library.json file for my application framework library. I added the change:

diff --git a/platformio.ini b/platformio.ini
index 9a3480b..722c3f4 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -54,4 +54,5 @@ upload_port = ${secrets.uploadPort}
 upload_flags =
        ${secrets.uploadAuth}
        ${secrets.uploadHostPort}
-;lib_ldf_mode = deep
+lib_ldf_mode = deep
+lib_compat_mode = strict

And that got my branch to build(!). I still see the rasberrypi dependency get installed and it is listed in the dependency tree, but the project did compile. I needed to use lib_ldf_mode = deep instead of deep+ to avoid errors for some reason.

Is the right thing really to update the library.json file in my og3 library instead?

Well, does it work with the library.json modification equally? That can cut down this conversation really short.

OK. I made a new release of my library, including the proposed changes in library.json. I found that without the corresponding changes in platform.ini in my project that includes the library, the build fails. When I add the changes back to projects’s platform.ini, then the project builds again.

So as far as I can tell, the changes in library.json doesn’t necessarily change the dependency resolution policy for projects which use the library (though maybe it does for the subtree below the library?).

One other thing to note is that I only have these build failures when I include my library from where it is published on platform.io. When I include the same library from my local file system using lib_extra_dirs then I don’t get the build failure, both with and without the changes to dependency resolution policy.

I really appreciate the help – it got my project un-stuck.

If deep is in a library.json the maintainer did a bad job.

My experience deep and deep+ generates more issues than it solves