How to resolve duplicate library dependencies when specified with URL?

I have two custom lib deps: M5Stack & M5ez. M5ez depends on M5Stack. But it should download the version I’ve pinned down in the platformio.ini file:

[env:frogboard]
platform = espressif32@4.4.0
board = frogboard
framework = arduino
lib_deps = 
  https://github.com/dizcza/M5ez.git#WESP32
  https://github.com/dizcza/M5Stack.git#K46v2
build_flags = -Ofast
  -DARDUINO_FROG_ESP32
  -DCORE_DEBUG_LEVEL=5

Instead, it downloads both versions, and I see two M5Stack folders in M5ez build directory:

Screenshot from 2023-04-10 11-01-57

This is because M5ez lib deps are:

name=M5ez
version=2.3.0
author=Rop Gonggrijp
maintainer=Rop Gonggrijp
sentence=Complete interface builder for the M5Stack, an ESP32 based mini tinker-computer
paragraph=See more on https://github.com/M5ez/M5ez
category=Display
url=https://github.com/M5ez/M5ez
architectures=esp32
includes=M5ez.h
depends=ezTime, M5Stack

This causes lots of redefined errors. I don’t have such a problem in Arduino IDE. I’m using VS + PlatformIO.

Full code: GitHub - dizcza/wt32-sc01-audio-monitor at frog

There’s no such issue when I just imported that project.

Looks like you have leftovers from when you started developing the libraries or used a different M5Stack. Just delete the .pio folder of the project and hit “Build” again to get a clean build.

Note that I had to add lib_ldf_mode = deep to the platformio.ini to make PlatformIO correctly recognize the dependencies between the libraries, otherwise it would get very confused with all the #ifdef #include <..> constructs. Then, compiling a src/main.cpp of

#include <Arduino.h>
#include <M5ez.h>
#include <M5StX.h>

void setup() {
    Serial.begin(115200);
}
void loop() {
    if(M5.BtnA.isPressed()) {
        Serial.println("A pressed!");
    }
}

went through sucessfully.

That’s because when you loaded the code I’d already updated my M5ez fork and removed M5Stack from the dependency list (see commit removed wifi · dizcza/M5ez@cf76a31 · GitHub). Sorry for that.

In order to reproduce the issue, please change the lib deps to the following:

lib_deps = 
  fastled/FastLED
  https://github.com/UT2UH/M5ez.git#WESP32
  https://github.com/dizcza/M5Stack.git#K46v2
  https://github.com/dizcza/SDP3x-Arduino.git
  ezTime

Under this setup, you’ll get

Library Manager: M5ez@2.3.0+sha.ea261a9 has been installed!
Library Manager: Resolving dependencies...
Library Manager: Installing M5Stack
Unpacking  [####################################]  100%
Library Manager: M5Stack@0.4.3 has been installed!
Library Manager: Installing ezTime
Unpacking  [####################################]  100%
Library Manager: ezTime@0.8.3 has been installed!
Library Manager: Installing git+https://github.com/dizcza/M5Stack.git#K46v2
git version 2.34.1
Cloning into '/home/dizcza/.platformio/.cache/tmp/pkg-installing-65dni75o'...
remote: Enumerating objects: 284, done.
remote: Counting objects: 100% (284/284), done.
remote: Compressing objects: 100% (243/243), done.
remote: Total 284 (delta 34), reused 186 (delta 31), pack-reused 0
Receiving objects: 100% (284/284), 2.08 MiB | 4.86 MiB/s, done.
Resolving deltas: 100% (34/34), done.
Library Manager: M5Stack@0.3.1+sha.f328557 has been installed!

So both M5Stack versions are downloaded and installed.

Thanks for the tip, I wasn’t aware of this flag.

It does not help though.