How to compile against the correct library version if multiple exist?

Hi PlatformIO community!

I’m aiming to provide a library to the PIO ecosystem that’s simple to work with. One thing that still puzzles me is how to handle different dependency versions if the project lives in the PIO registry. That’s how the dependency graph of the client project using my library looks like:

Dependency Graph
|-- <ArduinoJson> 6.15.1
|-- <MyLibrary> 0.1
|   |-- <ArduinoJson> 6.19.1

Although it downloads both versions of ArduinoJson, the compiler will compile all source files against only one version. However, both code bases rely on their specific version of ArduinoJson.

In this case, it is possible to just copy ArduinoJson into my repo and ship both together as it’s MIT-based. However, I’m curious about the most PIO-like way of compiling with multiple library versions in the libdeps folder. Is it good practice after all or should I rather force the user to just upgrade the common dependency in the client project before using my library?

Thank you!

This use case is not handled well in PlatformIO, I have seen this exact issue in forums post from maybe a year ago, but can’t find it again right now. Please open an issue with a minimum reproducable project at Issues · platformio/platformio-core · GitHub.

Thank you Max. Yes, I’ve done a lot of investigation on this before opening the thread and came accross similar questions. Yet nothing seemed like the “best practice” I’m looking for. Good, I will post it on the GitHub page