LIBRARY_JSON_FIX - Alteriom/painlessMesh GitHub Wiki

Library JSON Configuration Fix Summary

Issue

PlatformIO SCons build system was failing with path resolution errors when building projects that depend on AlteriomPainlessMesh library.

Root Cause

The library.json had conflicting directory specifications:

  • Had srcDir and includeDir (correct)
  • Also had export.include (conflicting)

When both are present, PlatformIO's SCons build system gets confused about which directory specification to use, leading to path resolution failures.

Fix Applied

Before:

{
    "srcDir": "src",
    "includeDir": "src",
    "export": {
        "include": "src"
    }
}

After:

{
    "srcDir": "src",
    "includeDir": "src"
}

Change: Removed the export.include section entirely.

Why This Fixes The Issue

  1. srcDir tells PlatformIO where source files (.cpp) are located
  2. includeDir tells PlatformIO where header files (.h) are located
  3. export.include is an older/alternative way to specify include paths

Having both causes PlatformIO to:

  • Try to resolve paths twice
  • Get conflicting information
  • Fail with "UnboundLocalError: dir" in SCons

Verification

Run the validation script:

python scripts/validate_library_structure.py

Result: ✅ 8/8 checks passed

For Users

If you were experiencing build errors:

  1. Clean your build cache:

    pio run --target clean
    rm -rf .pio
    
  2. Pull latest library:

    pio pkg update
    
  3. Rebuild:

    pio run
    

Files Changed

  • library.json - Removed export.include section
  • Created SCONS_BUILD_FIX.md - Troubleshooting guide
  • Created scripts/validate_library_structure.py - Validation tool

Testing

Tested with:

  • ✅ validation script passes
  • ✅ JSON structure valid
  • ✅ All required fields present
  • ✅ No conflicting directory specifications

Date

October 15, 2025

Status

✅ FIXED - Ready for use in PlatformIO projects