platformio / platformio/platformio-core

Project is built with include directories for two different versions of the same library

Open
#4,903 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

build system help wanted LDF
Dominant language
Python
Stars
9.5k
Forks
905
Avg merge
2d 13h
Merged PRs (30d)
2

Description

What kind of issue is this?

  • PlatformIO Core.
    If you’ve found a bug, please provide an information below.

You can erase any parts of this template not applicable to your Issue.


Configuration

Operating system: Ubuntu 20.04.6 LTS

PlatformIO Version (platformio --version): 6.1.14

Description of problem

Projects that use a newer version of a library (^3.1.0) but a dependency uses an older version of the same library (^2.3.0) are built with the include directories of both versions (and the older one has precedence).

Steps to Reproduce
  1. platformio run
Actual Results

Build fails because the project uses a function that is only present in the newer version of the library but the included header is from the older version.

Expected Results

Build is successful with only one version of the library's header files present.

If problems with PlatformIO Build System:

The content of platformio.ini:

[env:test]
lib_deps =
	nomis/uuid-log@^3.1.0
	nomis/uuid-modbus@^0.2.0 # depends on nomis/uuid-log@^2.3.0
lib_ldf_mode = chain

framework = arduino
platform = espressif8266@^3.0.0
board = d1_mini

Source file to reproduce issue:

#include <uuid/log.h>

static const char __pstr__logger_name[] __attribute__((__aligned__(PSTR_ALIGN))) PROGMEM = "test";

static uuid::log::Logger logger{FPSTR(__pstr__logger_name), uuid::log::Facility::KERN};

void setup() {
	logger.logp(uuid::log::Level::NOTICE, "test");
}

void loop() {
}
Additional info

This was introduced after 6.1.13, in 6.1.14:

$ git bisect ...
e1ff9a469d339b0fc4689a5e1520a89f14556a77 is the first bad commit
commit e1ff9a469d339b0fc4689a5e1520a89f14556a77
Date:   Tue Feb 13 19:32:57 2024 +0200

    Resolved an issue where the LDF selected an incorrect library version // Resolve #4860

 HISTORY.rst                            |  3 ++-
 platformio/builder/tools/piolib.py     | 17 ++++++++++---
 platformio/package/manager/_install.py |  6 ++++-
 platformio/package/meta.py             | 45 +++++++++++++++++++++++++++++-----
 4 files changed, 60 insertions(+), 11 deletions(-)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the regression commit e1ff9a469d339b0fc4689a5e1520a89f14556a77 and inspect platformio/builder/tools/piolib.py, platformio/package/manager/_install.py, and platformio/package/meta.py. Reproduce with the provided platformio.ini and source using PlatformIO 6.1.14, then compare against 6.1.13. Done means the dependency graph selects compatible headers so only the intended uuid-log version is included and the example builds successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.