Platformio is/can deleteting folders of symbolicatly linked libs

Using a platformio.ini on Windows (through pioarduino) that contains the following relevant snippets:

[platformio]

default_envs = esp32dev_debug

;default_envs = esp32dev_release

[common]

lib_deps_external =

    Adafruit_BusIO=symlink://../code_mcu_libs/lib/Adafruit BusIO@1.17.4

    Adafruit_GFX_Library=symlink://../code_mcu_libs/lib/Adafruit GFX Library@1.12.6

    Adafruit_MCP23017=symlink://../code_mcu_libs/lib/Adafruit MCP23017 Arduino Library@2.3.2

    Adafruit_PWM_Servo_Driver_Library=symlink://../code_mcu_libs/lib/Adafruit PWM Servo Driver Library@3.0.3

    Adafruit_SSD1306=symlink://../code_mcu_libs/lib/Adafruit SSD1306@2.5.16

[env]

extends = common

lib_ldf_mode = chain 

[common_esp32dev]

lib_deps =

    ${env.lib_deps_builtin}

    ${env.lib_deps_internal}

    ${env.lib_deps_external}

[env:esp32dev_debug]

extends = common_esp32dev

build_type = debug

The symlink is required because I don’t want to keep redundant copies of these files (not to mention speed of backup, etc.), and I also want to be sure that the three apps are drawing from the same resources in case I need to modify any of them.

There are 3 platformio files for 3 apps using two src folders, and these common libs (and more - but these are the problem ones) for one system. The de-referencing is to try and keep things simple, believe it or not! (Like changing from debug to release in one place).

When installing these libs (by changing platformio.ini), I ‘sometimes’ get these messages:

Resolving esp32dev_debug dependencies...

Removing unused dependencies...

Library Manager: Removing Adafruit SSD1306 @ 2.5.16

Library Manager: Removing dependencies...

Library Manager: Removing Adafruit GFX Library @ 1.12.6

Library Manager: Removing dependencies...

Library Manager: Removing Adafruit BusIO @ 1.17.4

Library Manager: Adafruit BusIO@1.17.4 has been removed!

Library Manager: Adafruit GFX Library@1.12.6 has been removed!

Library Manager: Adafruit SSD1306@2.5.16 has been removed!

Library Manager: Installing symlink://../code_mcu_libs/lib/Adafruit BusIO @ 1.17.4

PackageException: Can not create a symbolic link for `../code_mcu_libs/lib/Adafruit BusIO`, not a directory


And it is quite serious about the removal! Even if I set all the folders and contents to ‘read only’, it will actually delete these folders, despite being ‘symlink’ed. I am writing this while the issue is hot so I can recover get the error messages. So, I make the following observation, which might be the problem: I only noticed this after I added the ‘@’ version information. (It was for reference only - if I ever publish this I wanted the library versions used to be obvious.)

Nevertheless, this strikes me as very incorrect behaviour. It should IMHO flag a version ‘not correct’ error or something rather than just deleting the source folder - and then NOT FINDING IT (because it deleted it!)

Now, something also may be out of wack on my system (including a dirty pio folder). These are complex ESP32 apps (though I suspect this might apply to other MCUs), and big platformio.ini files. But if PlatformIO can somehow delete folders through symbolic links, especially if they are read-only, then there is a problem - somewhere, right?

On a hunch:

I replaced the folder names where there were spaces with an underscore ’ ’ to ‘_’.
Recovered the libs by getting platformio to download them.
Changed platfromio to have the symbolic liks (no version number and no spaces).

    Adafruit_BusIO=symlink://../code_mcu_libs/lib/Adafruit_BusIO ;@1.17.4
    Adafruit_GFX_Library=symlink://../code_mcu_libs/lib/Adafruit_GFX_Library ;@1.12.6
    Adafruit_MCP23017=symlink://../code_mcu_libs/lib/Adafruit_MCP23017_Arduino_Library ; @2.3.2
    Adafruit_PWM_Servo_Driver_Library=symlink://../code_mcu_libs/lib/Adafruit_PWM_Servo_Driver_Library ;@3.0.3
    Adafruit_SSD1306=symlink://../code_mcu_libs/lib/Adafruit_SSD1306 ;@2.5.16
    arduinoFFT=symlink://../code_mcu_libs/lib/arduinoFFT ;@2.0.4
    FastLED=symlink://../code_mcu_libs/lib/FastLED ;@3.10.3

Closed vscode
Deleted the pio folder.
opened vscode
(Twice after missing a space in in one of the names)

… and it seems to have fixed my direct issue of symlink lib folders being deleted while still leaving me a tad nervous.

So, on reflection, I think it was the spaces in the names that is the cause of the problem.

If spaces are not correctly taken into account from the platformio.ini and the folder / path logic for libraries, that’s a bug. Post a minimal reproducable example to https://github.com/platformio/platformio-core/issues/.

This was incomplete, and a tad wrong. The underscores did not make the difference, if was the addition or removal of the version information, as best I can tell.

In other words, Platformio treats ‘symlink’ just the same as if it had down loaded the lib into the ‘pio’ folder, so if thinks the old one should be gone - it is gone, and nothing you can do to stop it. The complexity is that this doesn’t seem to happen all the time or to every lib.

At least on my system, this is repeatable to the extent it has happened on more than one session. Not repeatable in that I can’t fully see the pattern yet.