Platformio ignores dependencies of local library

I’m trying to develop a library, which I then use in a separate project. I started out just including the library directory in lib_extra_dirs and manually adding all the necessary dependencies, but I’d like to set it up correctly as a library, and let the dependency manager take care of deps. In the code, GlowSystem is the library, GlowController is the project that tries to make use of it. They are both in the same parent directory.

I’ve a library.json file in GlowSystem:

file: GlowSystem/library.json
{
    "name":"GlowController",
    "version": "1.5.3",
    "description": "Control lots of LEDs in a nice way",
    "keywords":"LEDs",
    "repository":{
        "type": "git",
        "url": "https://github.com/mo-seph/GlowController"
    },
    "dependencies" : {
        "ArduinoJson": "7.0.4",
        "fastled/FastLED ": "3.6.0",
        "PubSubClient": "2.8",
        "LinkedList": "0.0.0-alpha+sha.dac3874d28",
        "Bounce2": "2.72",
        "adafruit/Adafruit BusIO": "1.16.0",
        "adafruit/Adafruit NeoPixel": "^1.12.0",
        "adafruit/Adafruit seesaw Library": "^1.7.5",
        "SPI": "2.0.0"
    },
    "platforms": "atmelavr, atmelsam, freescalekinetis, nordicnrf51, nxplpc, ststm32, teensy, espressif8266, espressif32, nordicnrf52",
    "build": {
        "libLDFMode":"deep"
    }
}

The platformio.ini in the importing project looks like this:

file: GlowController/platformio.ini

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[platformio]
default_envs = study_shelf
data_dir = data/default
extra_configs = wifi.ini

[env]
lib_ldf_mode = deep
framework = arduino
lib_deps =
  ArduinoJson @ 7.0.4
  GlowController @ 1.5.3

lib_extra_dirs =
    ../

build_flags =
board_build.filesystem = littlefs
board_build.partitions = default.csv 

monitor_speed = 115200
monitor_filters = send_on_enter



[env:study_shelf]
lib_deps =
  ArduinoJson @ 7.0.4
  GlowController
platform = espressif32
;platform = espressif32 @ 6.4.0
;platform = https://github.com/Jason2866/platform-espressif32.git#v2.0.3
board = esp32thing
;board = az-delivery-devkit-v4

monitor_speed = 115200
monitor_filters = send_on_enter
;upload_port = /dev/cu.usbserial-0001
;monitor_port = /dev/cu.usbserial-0001
upload_protocol = espota
upload_port = "study_shelf.local"
build_flags =
  -DDEVICE_NAME="Study Shelf Edge"
  -DDEVICE_ID="study_shelf"
  -DDEVICE_TYPE="beam_strip"
  -DNUM_LEDS=144
  -DLED_DATA_PIN=12
  -DWIFI_SSID=${wifi.ssid}
  -DWIFI_PASSWORD=${wifi.password}
  -DMQTT_SERVER=${wifi.mqtt_server}

when I run pio, I get:

> platformio run --environment study_shelf -v                
Processing study_shelf (lib_deps: ArduinoJson @ 7.0.4, GlowController; platform: espressif32; board: esp32thing; monitor_speed: 115200; monitor_filters: send_on_enter; upload_protocol: espota; upload_port: "study_shelf.local"; build_flags: -DDEVICE_NAME="Study Shelf Edge", -DDEVICE_ID="study_shelf", -DDEVICE_TYPE="beam_strip", -DNUM_LEDS=144, -DLED_DATA_PIN=12, -DWIFI_SSID="***", -DWIFI_PASSWORD="***", -DMQTT_SERVER="192.168.2.6"; lib_ldf_mode: deep; framework: arduino; lib_extra_dirs: ../; board_build.filesystem: littlefs; board_build.partitions: default.csv)
------------------------------------------------------------------------------------------------------------------------------------------------------------------
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32thing.html
PLATFORM: Espressif 32 (2024.3.10+sha.9ee162c) (git+https://github.com/Jason2866/platform-espressif32.git) > SparkFun ESP32 Thing
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, 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.0.0+sha.ec01775 (https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/2221/framework-arduinoespressif32-all-release_v5.1-ec01775.zip) 
 - tool-esptoolpy @ 4.7.2 (https://github.com/tasmota/esptool/releases/download/v4.7.2/esptool.zip) 
 - tool-mklittlefs @ 3.2.0 
 - tool-openocd-esp32 @ 2.1100.20220706 (11.0) 
 - tool-riscv32-esp-elf-gdb @ 12.1.0+20221002 
 - tool-xtensa-esp-elf-gdb @ 12.1.0+20221002 
 - toolchain-xtensa-esp32 @ 12.2.0+20230208
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ deep, Compatibility ~ soft
Library Manager: Installing ArduinoJson @ 7.0.4
Unpacking 0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100%
Library Manager: ArduinoJson@7.0.4 has been installed!
Found 32 compatible libraries
Scanning dependencies...
Warning: Ignored `FastLED ` dependency for `GlowController` library
Warning: Ignored `PubSubClient` dependency for `GlowController` library
Warning: Ignored `LinkedList` dependency for `GlowController` library
Warning: Ignored `Bounce2` dependency for `GlowController` library
Warning: Ignored `Adafruit BusIO` dependency for `GlowController` library
Warning: Ignored `Adafruit NeoPixel` dependency for `GlowController` library
Warning: Ignored `Adafruit seesaw Library` dependency for `GlowController` library
Dependency Graph
|-- ArduinoJson @ 7.0.4 (License: Unknown, Path: /Users/dmurrayrust/Dropbox/Projects/LivingRoomLEDs/GlowSystem/.pio/libdeps/study_shelf/ArduinoJson)
|-- GlowController @ 1.5.3 (License: Unknown, Path: /Users/dmurrayrust/Dropbox/Projects/LivingRoomLEDs/GlowController)
|   |-- ArduinoJson @ 7.0.4 (License: Unknown, Path: /Users/dmurrayrust/Dropbox/Projects/LivingRoomLEDs/GlowSystem/.pio/libdeps/study_shelf/ArduinoJson)
|   |-- SPI @ 2.0.0 (License: Unknown, Path: /Users/dmurrayrust/.platformio/packages/framework-arduinoespressif32@src-dbaf12675ed96229bba50503fda30b04/libraries/SPI)
|   |-- WiFi @ 2.0.0 (License: Unknown, Path: /Users/dmurrayrust/.platformio/packages/framework-arduinoespressif32@src-dbaf12675ed96229bba50503fda30b04/libraries/WiFi)
|   |-- ArduinoOTA @ 2.0.0 (License: Unknown, Path: /Users/dmurrayrust/.platformio/packages/framework-arduinoespressif32@src-dbaf12675ed96229bba50503fda30b04/libraries/ArduinoOTA)
|   |   |-- ESPmDNS @ 2.0.0 (License: Unknown, Path: /Users/dmurrayrust/.platformio/packages/framework-arduinoespressif32@src-dbaf12675ed96229bba50503fda30b04/libraries/ESPmDNS)
|   |   |   |-- WiFi @ 2.0.0 (License: Unknown, Path: /Users/dmurrayrust/.platformio/packages/framework-arduinoespressif32@src-dbaf12675ed96229bba50503fda30b04/libraries/WiFi)
|   |   |-- Update @ 2.0.0 (License: Unknown, Path: /Users/dmurrayrust/.platformio/packages/framework-arduinoespressif32@src-dbaf12675ed96229bba50503fda30b04/libraries/Update)
|   |   |-- WiFi @ 2.0.0 (License: Unknown, Path: /Users/dmurrayrust/.platformio/packages/framework-arduinoespressif32@src-dbaf12675ed96229bba50503fda30b04/libraries/WiFi)
|   |-- EEPROM @ 2.0.0 (License: Unknown, Path: /Users/dmurrayrust/.platformio/packages/framework-arduinoespressif32@src-dbaf12675ed96229bba50503fda30b04/libraries/EEPROM)
|   |-- LittleFS @ 2.0.0 (License: Unknown, Path: /Users/dmurrayrust/.platformio/packages/framework-arduinoespressif32@src-dbaf12675ed96229bba50503fda30b04/libraries/LittleFS)
|   |   |-- FS @ 2.0.0 (License: Unknown, Path: /Users/dmurrayrust/.platformio/packages/framework-arduinoespressif32@src-dbaf12675ed96229bba50503fda30b04/libraries/FS)
|   |-- Preferences @ 2.0.0 (License: Unknown, Path: /Users/dmurrayrust/.platformio/packages/framework-arduinoespressif32@src-dbaf12675ed96229bba50503fda30b04/libraries/Preferences)
|-- ArduinoOTA @ 2.0.0 (License: Unknown, Path: /Users/dmurrayrust/.platformio/packages/framework-arduinoespressif32@src-dbaf12675ed96229bba50503fda30b04/libraries/ArduinoOTA)
|   |-- ESPmDNS @ 2.0.0 (License: Unknown, Path: /Users/dmurrayrust/.platformio/packages/framework-arduinoespressif32@src-dbaf12675ed96229bba50503fda30b04/libraries/ESPmDNS)
|   |   |-- WiFi @ 2.0.0 (License: Unknown, Path: /Users/dmurrayrust/.platformio/packages/framework-arduinoespressif32@src-dbaf12675ed96229bba50503fda30b04/libraries/WiFi)
|   |-- Update @ 2.0.0 (License: Unknown, Path: /Users/dmurrayrust/.platformio/packages/framework-arduinoespressif32@src-dbaf12675ed96229bba50503fda30b04/libraries/Update)
|   |-- WiFi @ 2.0.0 (License: Unknown, Path: /Users/dmurrayrust/.platformio/packages/framework-arduinoespressif32@src-dbaf12675ed96229bba50503fda30b04/libraries/WiFi)

So:

  • It’s reading the library.json, and picking up the version number
  • It’s constructing a dependency tree, with the right deps in
  • It’s then ignoring them.

I’ve tried:

  • After reading Dependency of local Library not found - #8 by Atsunnytec, I’ve updated the library.json to the one shown above
  • If I try to force install pio lib install GlowControl, I get UnknownPackageError: Could not find the package with 'GlowControl @ 1.5.7' requirements for your system 'darwin_arm64'

Any suggestions?

Please note that according to the documentation lib_extra_dirs is deprecated since version 6.0 and the use of Local Folder and “Symbolic Link” feature is recommended.

By using symlink, the resolving of dependent libraries is performed without any problems.

Example

File and folder structure:

.
├── libraries
│   └── LibA
│       ├── src
│       │   ├── LibA.cpp
│       │   └── LibA.h
│       └── library.json
└── projects
    └── projectA
        ├── include
        ├── lib
        ├── src
        │   └── main.cpp
        ├── test
        └── platformio.ini

LibA/library.json

{
    "name" : "LibA",
    "version" : "1.0.0",
    "dependencies" : {
        "bblanchon/ArduinoJson" : "^7.0.0"
    }
}

projectA/platformio.ini

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
lib_deps = 
  LibA = symlink://../../libraries/LibA

Output of pio run:

Processing esp32dev (platform: espressif32; board: esp32dev; framework: arduino)
--------------------------------------------------------------------------------
Library Manager: Installing symlink://../../libraries/LibA
Library Manager: LibA@1.0.0 has been installed!
Library Manager: Resolving dependencies...
Library Manager: Installing bblanchon/ArduinoJson @ ^7.0.0
Unpacking  [####################################]  100%
Library Manager: ArduinoJson@7.0.4 has been installed!

This works great! Thanks!

1 Like