Changes in library are being overwritten upon build?

Hello,
I have to admit i am new to platformio and to cpp programming, thus please excuse if this is a kindergarden question.

I loaded a library using PIO lib install. now i would like to adjust a few things in this library (simply adding a printf for debug) But whenever I build the project, my code is being overwritten and the standard is restored.

so the question is, how can I modify a library with some custom code.

Thanks
Robert

Do you edit library in .pioenvs directory? See warning block in documentation:

In PlatformIO 2.0 that libraries are installed to lib_dir. Please edit libary here ~/.platformio/lib.

Got it, thanks a lot!! I need to get more familiar with the docs it seems

hi! I have similar problem - I need to do some changes in library installed by “pio lib install”,
(remove unused things)
but I’d like to do this in the safest possible fashion - I don’t want to do these changes in ‘globally installed library’, but only for this particular project. (because I suppose I will be using this library yet for other projects, also very likely my changes will be overwritten by further upgrade/update of platformio/libs.

What would be best approach to do this ?

PlatformIO 3.0 (has not been released yet) or after library installation, please remove .library.json file. PlatformIO will not update it.

Or you can put library source in lib/ subdrectory of your project. This way it will be project-private and will override the global one. In case of most libraries the source available in some kind of public repository.

ha, ok , I will try to use lib/ subdirectory then. Thanks.
And anwyay - PlatformIO 3.0 is tempting, especially after Ivan mentioned possibility to use custom build options (optimizations). I will need that too. :slight_smile: