Library not getting rebuilt into project

I have a project that uses: lib_extra_dirs = ~/Documents/Arduino/libraries

When I edit main.cpp it builds, loads and run as expected

If I edit myLib.cpp in the .’~/Documents/Arduino/libraries’ directory my edits don’t become part of the new build.

Example: If I edit print(“abc”); to print(“xyz”); in myLib.cpp. Then ‘clean’, ‘build’ and ‘load’ it prints “abc” instead of “xyz”.
If I remove the terminating ‘;’ from the same file PIO reports the error as it should.

What am I doing wrong???

I found the solution and a BUG I think.

In main.cpp I have an include for ‘routines’.

In my …/Arduino/libraries/Routines directory I have the files ‘routines.cpp’ and ‘routines,h’.

I also had a couple old versions, ‘routines old.cpp’ and ‘routines 2.cpp’ these were also being compiled along with the desired ‘routines.cpp’. this was causing my error.

When I renamed them to ‘ZZZroutines old.cpp’ and ‘XXXroutines 2.cpp’ they were also added into the compile by PIO.

PIO compiles all files in you library directory with the ‘.cpp’ extension into your project. Is this the way it is supposed to work??? I thought it would only include the file with the name in the include statement.

PIO compile all C/C++ related files by default. You can control it with Redirecting...