Library location for development

I am trying to understand the best way to develop a project and a global library in parallel.

I have a library called Lorro_BQ4050 that is in .platformio\lib\Dev folder. I have placed it in the \Dev folder and within the folder is included a git local repo. It is in this location and not just in the lib folder because if I test the platformio library update procedure from the platformio library registry, platformio replaces all files in the \lib folder with the files in the github repo and hence deletes the local git repo.

Currently the only way I can get it to work is by using the terminal and calling
pio lib --global install Dev\Lorro_BQ4050
This is fine, but then when I change the library at all, from the location, I have to uninstall the library then re-install it to update it.

With the library uninstalled, I have tried writing lib_deps and lib_extra_dirs in platformio.ini with the following paths
= \Dev
= \Dev\Lorro_BQ4050
= C:\Users\myName\.platformio\lib\Dev
= C:\Users\myName\.platformio\lib\Dev\Lorro_BQ4050

I’ve also tried pio lib --global update \Dev\Lorro_BQ4050, which says it runs OK, but doesn’t update the library.

Is there an easier way to develop a library like this?


Why is it in the .platformio folder? It is to be expected that PlatformIO would overwrite anything you put there, as it’s mean to be it’s own working space. Clone the repo into the top level lib folder for your project, and you’ll be fine then, as PlatformIO won’t try to change that folder. Make your changes, test them, and then push a new library version when you’re ready to have a new release.

To ‘test’ the PlatformIO library update update procedure, you’re going to have to make a version change in your repo, and then wait for 24+ hours for the library crawler to see the changes. You should then see the new version registered when you check the listing on the PlatformIO Registry for your library. e.g. it currently reports it to be v0.2, released last week.

Also, why does it need to be a global library? You should avoid installing libraries globally wherever possible, as it will result in errors if you try to compile a unrelated project on a unsupported platform as the library is still in the include path. Global install has given me some rather puzzling errors at times.

Thanks for the advice.

So as I understand, I shouldn’t put anything in the /platformio folder or subfolders.

For using libraries that I’m actively working on, only use the platformio.init file for that project and add lib_extra_dirs = C:\Users\myName\libraries
In the libraries folder, myLibrary\myLibrary.h is located.

And in general, only install your own libraries globally as a way to test them, but uninstall them for general project use (use above method for each project instead)