question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Library dependency resolution relies on lib_deps=... order

See original GitHub issue

Configuration

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

  1. 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:closed
  • Created 3 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
mcsprcommented, Apr 11, 2022

Thanks for the report! Please re-test with pio upgrade --dev.

PoC repo works now, thanks! https://github.com/mcspr/pio-poc-libdeps-order/runs/5971294721?check_suite_focus=true

Dependency Graph
|-- AsyncMqttClient @ 0.8.1+sha.ddbf4d1
|   |-- ESPAsyncTCP @ 1.2.0+sha.7e9ed22
|-- ESPAsyncTCP @ 1.2.0+sha.7e9ed22
|-- ESP8266WiFi @ 1.0
|-- Hash @ 1.0
0reactions
ivankravetscommented, Apr 8, 2022

Thanks for the report! Please re-test with pio upgrade --dev.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Library options — PlatformIO latest documentation
Specify project dependencies using Package Specifications that should be installed automatically to the libdeps_dir before environment processing.
Read more >
LIBDEPS_DEPENDENTS does not resolve library names ...
Listing a library in LIBDEPS means that the current library depends on that library, while listing any target in LIBDEPS_DEPENDENTS means that ...
Read more >
Understanding dependency resolution
This chapter covers the way dependency resolution works inside Gradle. ... Keeping order in a very large graph can be a challenge. For...
Read more >
Why does the order in which libraries are linked sometimes ...
Dependencies of static libraries against each other work the same - the library that needs symbols must be first, then the library that...
Read more >
Deps and CLI Guide
To work with this library, you need to declare it as a dependency so the tool can ensure ... tool which will list...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found