Library dependency resolution relies on lib_deps=... order
See original GitHub issueConfiguration
Operating system:
Fedora Server 32
PlatformIO Version (platformio --version
):
PlatformIO, version 4.4.0a5
(a2efd7f7c523e92963bbec6154c6c58ec2f1bc68)
Description of problem
Library specified in lib_deps, but also specified in other dependent library’s library.json requirements gets detected twice after scanning for dependencies and also gets linked twice.
Project in question uses ESPAsyncTCP and async-mqtt-client. Depending on which one is specified first in the lib_deps, different versions of ESPAsyncTCP are installed.
Compilation issue comes from ESPAsyncTCP having slightly different signatures of onError(), where int8_t type is replaced with err_t. Main application uses the old version, while async-mqtt-client uses the 2nd b/c of the initial dependency scan, so linking with both libraries isn’t possible.
Steps to Reproduce
With project structure as described below
pio run
Actual Results
See https://github.com/mcspr/pio-poc-libdeps-order/runs/875651792?check_suite_focus=true#step:5:1 (5th step, “Run without installing libs manually”)
When ESPAsyncTCP comes before async-mqtt-client, it is installed first and async-mqtt-client dependency gets satisfied. When async-mqtt-client comes before, PIO registry version gets installed first and lib_deps version second.
Having two libraries at the same time causes build process to try to include both at the same time.
Expected Results
(?) Not really sure about this one. Based on previous version of PIO, it worked fine with the stable release
If problems with PlatformIO Build System:
The content of platformio.ini
:
[env]
platform = espressif8266
board = d1_mini
framework = arduino
[env:ok]
lib_deps =
https://github.com/me-no-dev/ESPAsyncTCP.git#7e9ed22
https://github.com/marvinroger/async-mqtt-client#v0.8.1
[env:fail]
lib_deps =
https://github.com/marvinroger/async-mqtt-client#v0.8.1
https://github.com/me-no-dev/ESPAsyncTCP.git#7e9ed22
Source file to reproduce issue:
// main.cpp
#include "main.h"
#include <cstdint>
AsyncMqttClient mqtt;
AsyncClient client;
void setup() {
Serial.begin(115200);
WiFi.begin("SSID", "PASS");
mqtt.connect();
mqtt.publish("test", 0, false, "test");
// <<<
// it is important that we try to use incompatible function from a version different from the one that gets linked with mqtt client
client.onError([](void*, AsyncClient* c, int8_t err) {
Serial.printf(PSTR("Error %s (%d) on client %p\n"), c->errorToString(err), err, c);
});
// >>>
client.connect("foo.bar", 80);
}
void loop() {
}
// main.h
#pragma once
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <Hash.h>
#include <ESPAsyncTCP.h>
#include <AsyncMqttClient.h>
Additional info
- not sure if header or cpp matters when dealing with ldf, but keeping deps in header for the sake of the experiment
- installer.py is a helper script that was assumed as the culprit initially, but as it turns out issue is easily reproducible even without it
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (9 by maintainers)
PoC repo works now, thanks! https://github.com/mcspr/pio-poc-libdeps-order/runs/5971294721?check_suite_focus=true
Thanks for the report! Please re-test with
pio upgrade --dev
.