After installing and uninstalling a local library the source code is gone. I would expect that install and uninstall only affects the folders on the lib path (~/.platformio/lib/) and would not remove the original source code.
On a path with a TheLib directory:
pio lib -g install TheLib
pio lib -g uninstall TheLib
removes the TheLib folder in the local dir and not in ~/.platformio/lib/TheLib dir.
On a path with a TheLib directory:
pio lib -g install TheLib
pio lib -g uninstall TheLib
pio lib -g uninstall TheLib
removes first the TheLib folder in the local dir and then the ~/.platformio/lib/TheLib dir.
Is there a solution to this besides changing directory?
With local dir I mean the directory where I am.
E.g. my source is at ~/git/TheLib, I am in ~/git/, pwd gives ‘/home/gerben/git’
To reproduce this behavior:
mkdir TheLib
mkdir TheLib/src
touch TheLib/src/TheLib.h
touch TheLib/src/TheLib.cpp
touch TheLib/platformio.ini
cd TheLib
pio run
cd …
pio lib -g install ./TheLib
pio lib -g uninstall TheLib
I would expect my source code to still be under ~/git/TheLib and ~/.platformio/lib/TheLib removed.
But at this stage the source folder ~/git/TheLib is deleted by pio and ~/.platformio/lib/TheLib still exists.
Doing a second
pio lib -g uninstall TheLib
Removes ~/.platformio/lib/TheLib
Nevertheless, take a look at lib_extra_dirs, you do not need to install twice local library. Just add new extra storage and PIO will use your local library automatically.