Bug Report - symlink in platformio.ini

I believe there is a bug when deleting a symlink from lib_deps in platformio.ini
If you have accidentally placed an incorrect symlink and delete it the references are not removed from the .pio directory and platformio will error every time you try to add a new library.

Example:
Place lib_deps = symlink://../MyLibrary into platformio.ini that already contains some library references. If this is an incorrect path there will be no library.json file. PlatformIO will error. Delete the symlink from platformio.ini and try to install another library and you get the No library.json error. Restart and same error. The references do not disappear from these locations. Deleting them manually fixes the error.

Project/.pio/libdeps/integrity.dat
Project/.pio/libdeps/MyLibrary.pio-link

Even this is the community forum, I tried to reproduce this - without success

Here is my folder initial structure:

.
├── MyLibA
│   ├── src
│   │   ├── MyLibA.cpp
│   │   └── MyLibA.h
│   └── library.json
├── MyLibB
│   ├── src
│   │   ├── MyLibB.cpp
│   │   └── MyLibB.h
│   └── library.json
└── Project
    ├── .pio
    ├── include
    ├── lib
    ├── src
    │   └── main.cpp
    ├── test
    └── platformio.ini

Here is the initial platformio.ini

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino

Step 1: Adding a valid symlink to MyLibA

lib_deps = 
  symlink://../MyLibA

Results in

.
├── .pio
│   ├── build
│   └── libdeps
│       └── esp32dev
│           ├── integrity.dat
│           └── MyLibA.pio-link
├── include
├── lib
├── src
│   └── main.cpp
├── test
└── platformio.ini

Step 2: Adding a faulty symlink //../../MyLibB

(The correct symlink would be //../MyLibB):

lib_deps = 
  symlink://../MyLibA
  symlink://../../MyLibB

Results in an error message:

Resolving esp32dev dependencies...
Library Manager: Installing symlink://../../MyLibB
PackageException: Can not create a symbolic link for `../../MyLibB`, not a directory

Step 3. Removing the faulty link

lib_deps = 
  symlink://../MyLibA

Output:

Resolving esp32dev dependencies...
Already up-to-date.
Updating metadata for the vscode IDE...
Project has been successfully updated!

No changes in the filesystem

Step 4. Adding the correct link to //../MyLibB

lib_deps = 
  symlink://../MyLibA
  symlink://../MyLibB

Output:

Resolving esp32dev dependencies...
Already up-to-date.
Updating metadata for the vscode IDE...
Project has been successfully updated!

Filesystem:

.
├── .pio
│   ├── build
│   └── libdeps
│       └── esp32dev
│           ├── integrity.dat
│           ├── MyLibA.pio-link
│           └── MyLibB.pio-link
├── include
├── lib
├── src
│   └── main.cpp
├── test
└── platformio.ini

Everything looks correct to me.

But what I have noticed is, when you remove all lib_deps - there will no automatic clean up of the libdeps folder.

Fortunately, that’s what PROJECT TASKS / Default / General / Full Clean is made for :slight_smile:

Thanks @sivar2311
I wasn’t sure if it was a bug or if I was doing something wrong since I’m really new to using PlatformIO. I didn’t know there was a “full clean” option. I’ll use that from now on.