Effect of '^' in lib_deps

In platformio.ini I have the line:

lib_deps = fastled/FastLED@^3.9.2

The latest version of FastLED is currently 3.9.12. The issue I’m having is that (after restarting VScode, working on other projects etc.) the version that is being used often changes between 3.9.2 and 3.9.12 when I build the project. I’m struggling to find any definitive documentation of what the ‘^’ is supposed to do but my understanding is that it specifies the minimum version of the library.

ChatGPT thinks this might be a caching issue but I’m wondering if I’m misunderstanding something here.

(The reason to use 3.9.2 is that 3.9.12 won’t compile on some platforms. I filed an issue in Github.)

Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32-c3-devkitm-1.html
PLATFORM: Espressif 32 (6.10.0) > Espressif ESP32-C3-DevKitM-1
HARDWARE: ESP32C3 160MHz, 320KB RAM, 4MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-builtin, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-arduinoespressif32 @ 3.20017.241212+sha.dcc1105b
 - tool-esptoolpy @ 1.40501.0 (4.5.1)
 - toolchain-riscv32-esp @ 8.4.0+2021r2-patch5
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 34 compatible libraries
Scanning dependencies...
Dependency Graph
|-- FastLED @ 3.9.2
Building in release mode
Retrieving maximum program size .pio\build\esp32-c3-devkitm-1\firmware.elf
Checking size .pio\build\esp32-c3-devkitm-1\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   4.4% (used 14356 bytes from 327680 bytes)
Flash: [==        ]  18.3% (used 239580 bytes from 1310720 bytes)
========================================================================================================= [SUCCESS] Took 6.41 seconds =========================================================================================================

The ^ means “the latest compatible version”

See pio pkg install — PlatformIO latest documentation

1 Like

Semantic Versioning (semver) is documented at https://docs.platformio.org/en/latest/core/userguide/pkg/cmd_install.html#version-requirements

^1.2.3 means that any 1.x.x version is accpeted.
~1.2.3 means that any 1.2.x version is accepted.

Etc.

Note that often times, library authors don’t care about correct semantic version and introduce breaking API changes with only an increase in minor version anyway.

1 Like

Thanks for the link but I’m still unsure why it is (apparently) randomly switching between the two versions.

And yes, version 3.9.12 breaks compatibility, for me at least.

Thanks for the link but it’s not working as it should.

We highly recommend pinning a package to a Registry: Specific Version and to prefix the version with the ^ (caret) symbol. This will instruct PlatformIO to install the latest compatible version avoiding breaking changes in the future.

It may well install the latest version but it’s not always using it. Maybe this is a bug?

Do you delete the .pio folder in the project before making that change? What SemVer version are you giving and what version does it download into `.pio/libdeps

I’ve been though all the combinations of deleting 3.9.2, deleting 3.9.12, deleting both and deleting neither, and I now can’t cause it to use 3.9.2. This was an older project using 3.9.2 so when I initially tried rebuilding it, I’m wondering if there was a network issue that prevented it updating to 3.9.12.

Do you use other dependencies that can potentially depend strictly on FastLED@3.9.2?