PlatformIO Community

How to handle nested lib_deps in custom libraries (dependency chains)

I’ve recently started using the library functionality of PlatformIO, and find it quite nice and convenient. But I’m struggling with figuring out how to handle dependency chains, and cannot seem to find an answer on google/SO/this forum.

I have a project P, which has a dependency on a library A, which I made. Library A has a dependency on library B (which I made as well). Both library A and library B have their own repository, a library.json file and a platform.ini file… Library A has a lib_deps entry for library B, and project P has a lib_deps for library A (but not for library B).

When I do pio lib install from my project P, only the library A gets pulled in.

I realize I can add library B to the lib_deps of project P, but since P is not directly dependent on B this seems wrong, and it will entail some added bookkeeping and complexity in ensuring that the dependencies on B are kept in sync wrt version… Am I missing something obvious? What would be best practice here?

Ok, found the solution shortly after posting this (typical!).

So in library A, I had only declared the dependency of library B inside the platform.ini file. Instead, this should have been in the library.json (of libraryA), under dependencies:

 "dependencies": [
    {
      "name": "libraryA",
      "version": "https://github.com/myorg/libraryB#v1.0.0"
    }
  ]

After doing this, everything works as expected