PlatformIO Community

What is the proper way to remove dependency?

What is the proper way to remove a dependency? Or more specifically: What do I need to do so PlatformIO removes it from .pio/libdeps/board/ once I have remove it from platformio.ini?

Here’s an example:


platform = atmelavr
board = uno
framework = arduino


#include <Arduino.h>
#include <IRremote.h>

IRrecv ir(10);
decode_results results;

void setup() {

void loop() {
    if (ir.decode(&results)) {

Step 1: Add dependency

This code does not compile as the IRremote library is needed. As expected, the error message is:

src/main.cpp:2:22: fatal error: IRremote.h: No such file or directory

So the following lines are added to platformio.ini:

lib_deps =

Now the project successfully builds. So far everything is as expected. :slight_smile:

Step 2: Remove the dependency

Now we remove lib_deps from platformio.ini and revert to the initial, invalid configuration. Even though a library dependency is missing, the project still builds successfully. :frowning:


The reason is that the library is still present in .pio/libdeps/uno/IRremote_ID4. Neither pio run -t clean nor pio lib update won’t help. The latter one even lists the library even though it is no longer presennt in platformio.ini.

This is surprising because installing a library is automatic and uninstalling is not. If the project is pushed to git and checked out in a different place, it won’t compile. Beginners also seem to struggle regularly with this surprising behaviour as can be witnessed in this forum. The unfortunate result is that PlatformIO appears to be an unreliable tool.

Of course, I understand that I can remove the .pio folder to get rid of the dependency. But isn’t there any better way? Shouldn’t it happen automatically when platformio.ini has been changed and the project is rebuilt? Or at least when the clean target is run?


@ivankravets Can you comment on this? Wouldn’t it make sense to automatically delete dependencies that are no longer referenced in platformio.ini?

Sorry for the delay. We hard work on something cool for PlatformIO. Stay tuned :slight_smile:

As for your issue - this is a bug, please report to Issues · platformio/platformio-core · GitHub

We plan to introduce new Package Registry soon. So, you will not need to use these magic number more, such as lib_deps = 4. Today, we don’t have unique pair for library dependency. A lot of libraries use the same name which leads a lot of problems.The format will be the next:

lib_deps = @owner/libraryName


lib_deps = @owner/libraryName@~1.2.3

If we will have 1:1 information about your dependencies, we can control them properly.

1 Like

Now 1.5 year later the dependency information is updated but removing a dependency from lib_deps in platformio.ini still doesn’t remove its files from the .pio/libdeps/board/ folder.


And another year later the problem persists.

I have bashed my head against this problem problem several times and very sad to see that it has STILL not been fixed!

And noone ever filed an issue in the Github, why is that?

I’ve opened one at now.


Ah, that makes sense. Thanks for opening the Github issue, fingers crossed the next post here will be about it being resolved :smile:

This still does not seem to be resolved despite a purported fix in: Old dependencies are not removed from .pio folder · Issue #3076 · platformio/platformio-core · GitHub My libdeps folder is still full of miscellaneous versions of the same libraries from who knows where.

I found multiple issues filed in Github about this, at least three in 2019, 2020, and 2021.

The brittleness and overbearingness of the PIO library manager is why I’ve tried to avoid using it. And yet then I constantly run into issues like this one (undefined reference to `Adafruit_FlashTransport_QSPI::Adafruit_FlashTransport_QSPI()' · Issue #116 · adafruit/Adafruit_SPIFlash · GitHub) where the “fix” is “why aren’t you just using the library manager?” Really frustrating.

Do you use the latest PlatformIO Core? Could you try to reproduce this issue on the clean project?

Why is it even an issue? You can just delete .pio folder entirely. If I understand correctly, it is like a cache and will be recreated on the next rebuild.

1 Like

Is it, though? Looks like this was the original issue from several years ago.