Repository navigation
LIBRARY_STRUCTURE_FIX
Date: October 14, 2025
Issue: PlatformIO build errors when using AlteriomPainlessMesh as a dependency
Root Cause: Missing directory specifications and duplicate library metadata
Problem: The root library.json didn't explicitly declare where source files are located.
Impact: PlatformIO couldn't reliably resolve file paths, causing compilation errors like:
Error: Cannot resolve directory for painlessMeshSTA.cpp
UnboundLocalError: cannot access local variable 'dir'
Problem: A second library.json file existed inside src/ directory.
Impact: Caused path resolution conflicts and confused PlatformIO's build system about which metadata to use.
Problem: library.properties referenced AlteriomPainlessMesh.h but examples use painlessMesh.h.
Impact: Arduino IDE users would have include path issues.
File: library.json
Changes:
{
"srcDir": "src",
"includeDir": "src"
}Why: Explicitly tells PlatformIO where to find source files and headers, eliminating path resolution ambiguity.
File: src/library.json (DELETED)
Why: Only one library.json should exist at the library root. Having metadata in src/ creates conflicts.
File: library.properties
Before:
includes=AlteriomPainlessMesh.hAfter:
includes=painlessMesh.hFile: library.json
Added:
"headers": ["painlessMesh.h", "AlteriomPainlessMesh.h"]Why: Both headers exist and may be used. The primary header is painlessMesh.h (matches examples), but AlteriomPainlessMesh.h is also available for compatibility.
File: package.json
Before:
"scripts": {
"build": "cmake -G Ninja . && ninja",
"prebuild": "git submodule update --init"
}After:
"scripts": {
"dev:build": "cmake -G Ninja . && ninja",
"dev:prebuild": "git submodule update --init"
}Why: Prevents automatic build script execution during npm link or npm install, which was causing Python errors in npm consumers.
painlessMesh/
├── library.json ← ROOT metadata (ONLY copy)
├── library.properties ← Arduino IDE metadata
├── package.json ← npm metadata
├── src/ ← Source directory (specified in library.json)
│ ├── painlessMesh.h ← Primary header (used in examples)
│ ├── AlteriomPainlessMesh.h ← Alternative header
│ ├── painlessMeshSTA.cpp ← Implementation files
│ ├── painlessMeshSTA.h
│ ├── scheduler.cpp
│ ├── wifi.cpp
│ ├── painlessmesh/ ← Core library modules
│ ├── arduino/ ← Platform-specific code
│ ├── boost/ ← Boost headers (for PC builds)
│ └── plugin/ ← Plugin system
├── examples/ ← Example sketches
└── docs/ ← Documentation
# In your project that depends on AlteriomPainlessMesh
pio lib install https://github.com/Alteriom/painlessMesh#copilot/start-phase-2-implementation
pio runExpected Result: ✅ Clean compilation with no path resolution errors
- Install library via Library Manager or ZIP
- Open
File > Examples > AlteriomPainlessMesh > startHere - Compile for ESP32 or ESP8266
Expected Result: ✅ Successful compilation
# In painlessMesh repo
npm link
# In dependent repo
npm link @alteriom/painlessmeshExpected Result: ✅ No build errors, no Python errors
platformio.ini:
[env:esp32]
platform = espressif32
board = esp32dev
framework = arduino
lib_deps =
https://github.com/Alteriom/painlessMesh#copilot/start-phase-2-implementationInclude statement:
#include <painlessMesh.h>package.json:
{
"dependencies": {
"@alteriom/painlessmesh": "github:Alteriom/painlessMesh#copilot/start-phase-2-implementation"
}
}- Root
library.jsonhassrcDirandincludeDirspecified - No duplicate
library.jsonfiles exist in subdirectories -
library.propertiesreferences the correct primary header - Source files (
.cpp,.h) are insrc/directory - Examples compile without path errors
- npm scripts don't interfere with package consumers
- Headers array includes both header file variants
Status: ✅ FIXED
Tested: Ready for testing in dependent projects
Next Steps: Test compilation in external PlatformIO projects