Howto: use local git repo during library development

OK, I have made a library, given it a library.json, uploaded the first iteration to github, and created a lib_deps=…@^0.2.0 entry in platform.ini. This is working well for two different main.cpp projects.

It is now time for the next iteration of the library. So how can I test changes without committing & uploading the library for each change and changing the platformio.ini in the testing harness? I’d really rather not temporarily go back to a lib_dir directive.

Ideally, I would have both the library and the test harness main.cpp folder in the workspace to make coordinated changes to both, compile both, and then load to the target for testing. And then when working commit the changes for the next library release.

Is there a platformio.ini command to alter the order the library manager uses to find libraries? i.e. look first to local git repo before downloading repo from github? Could library manager be more selective in looking only in local repo if version not found at github?

This is how I do it (PlatformIO & VS code):

Create a new project and add the library to the lib_deps in platformio.ini:
lib_deps =

The library is then automatically cloned under .pio/<environment-name>/libdeps/<library-name>/.
In this folder you can make changes to the library and test these changes it in your project.

In VS code, the changes can then be comitted via the source control panel and pushed to github.

Alright! Finally, a method that works with minimal fuss. I was under the mis-apprehension that the .pio/lib_deps tree was rebuilt for each compile.

I’m still not sure what triggers the library manager to rebuild the .pio/lib_deps tree. But this works for now, and I will commit changes before closing vscode.

Perhaps someone can enlighten me on the best practice of when to commit to prevent data loss.

You do not need to commit the changes before closing VS Code.
The changes will be kept :slight_smile:

If what you want is to dev and test libraries locally then you could take a look at GitHub - davetcc/tcLibraryDev: This repo is for developers wanting to use platformIO to develop and test tcMenu and IoAbstraction

It’s what I and a few others use for library development and has some instructions, they are aimed at my libraries but adjusting shouldn’t be difficult.

EDIT - It boils down to putting the library in the local libs directory which is picked up during the build. I usually use the default and that’s named “lib” at the project root, if you put your library repos in there, you won’t even need to configure anything.

See Library Dependency Finder (LDF) — PlatformIO v6.1 documentation where it is explained in detail.

You can even then test all your examples in turn easily by overriding the source directory for example:

src_dir = lib/tcMenu/examples/arduino32/piPicoTftEncoder
;src_dir = lib/tcMenu/examples/mbed/stm32OledEncoder
;src_dir = lib/LiquidCrystalIO/examples/aw9523Example
... omitted the rest for clarity