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?

1 Like

@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

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