platformio / platformio/platformio-core

Environment Switching Requires .pio Cleanup on Windows

Open
#5,348 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Problem Summary

When switching between build environments on Windows (but not WSL), PlatformIO fails to compile with "No such file or directory" errors for library headers. The issue requires deleting the environment-specific libdeps directories.

Environment

  • OS: Windows. Issue does NOT occur on WSL.
  • Platform: ESP32 (espressif32)
  • Board: M5Stack StampS3
  • Framework: Arduino
  • PlatformIO Configuration: See below

Steps to Reproduce

  1. Delete the .pio folder (clean state)
  2. Select environment release
  3. Build → ✅ Compiles successfully
  4. Switch to environment debug
  5. Build → ❌ Fails with header file errors like:
    foo.cpp:7:10: fatal error: bar.h: No such file or directory
    

Note: This occurs with any environment switch (debug ↔ release, debug ↔ debugNoBle, etc.)

Current Workarounds Tested

  • Deleting .pio/libdeps/debug → Fixes the issue

Configuration Details

Full platformio.ini
[platformio]
default_envs = debug
build_cache_dir = ${platformio.core_dir}/build_cache

##################################################

[env]
platform = https://github.com/pioarduino/platform-espressif32/releases/download/55.03.35/platform-espressif32.zip
board = m5stack-stamps3
framework = arduino
monitor_speed = 115200
board_build.partitions = huge_app.csv
monitor_filters = esp32_exception_decoder
build_unflags = 
  -Os
  -Werror=all
  -std=gnu++2a 
  -std=gnu++2b
  -fno-rtti
build_flags = 
  -std=gnu++23
  -I".pio/libdeps/${PIOENV}/M5Unified/src" ; Required for lib_ldf_mode = off
  -I".pio/libdeps/${PIOENV}/M5GFX/src" ; Required for lib_ldf_mode = off
  -I"${platformio.packages_dir}/framework-arduinoespressif32/libraries/Wire/src" ; Required for lib_ldf_mode = off
  -I"${platformio.packages_dir}/framework-arduinoespressif32/libraries/SPI/src" ; Required for lib_ldf_mode = off
  -I"${platformio.packages_dir}/framework-arduinoespressif32/libraries/Preferences/src" ; Required for lib_ldf_mode = off
lib_deps = 
  symlink://../../../AzzLibs/ImuTools
  symlink://../../CapsuleComponents
  Wire ; Required for lib_ldf_mode = off
  SPI ; Required for lib_ldf_mode = off
  Preferences ; Required for lib_ldf_mode = off
lib_ldf_mode = off

##################################################

[ble]
lib_deps = 
  symlink://../../../AzzLibs/BleTasksForSlAndSp
build_src_filter = +<*> -<.git/> -<.svn/> -<old/>
build_flags = 
  -D ENABLE_BLE=true

[noBle]
lib_deps = 
  symlink://../../../AzzProtocol/lib_cpp
  symlink://../../../AzzLibs/NetVar
  symlink://../../../AzzLibs/Os
build_src_filter = +<*> -<.git/> -<.svn/> -<tasks/BleTask.cpp> -<old/>
build_flags = 
  -D ENABLE_BLE=false 

##################################################

[debug]
build_type = debug
build_flags = 

[release]
build_type = release
build_flags = 
  -DNDEBUG 
  -O3
  
##################################################

[env:debug]
extends = debug
lib_deps = ${env.lib_deps} ${ble.lib_deps}
build_flags = ${env.build_flags} ${ble.build_flags} ${debug.build_flags}
build_src_filter = ${ble.build_src_filter}

[env:debugNoBle]
extends = debug
lib_deps = ${env.lib_deps} ${noBle.lib_deps}
build_flags = ${env.build_flags} ${noBle.build_flags} ${debug.build_flags}
build_src_filter = ${noBle.build_src_filter}

[env:release]
extends = release
lib_deps = ${env.lib_deps} ${ble.lib_deps}
build_flags = ${env.build_flags} ${ble.build_flags} ${release.build_flags}
build_src_filter = ${ble.build_src_filter}

##################################################

Additional Context

This environment switching issue is part of a long-standing pattern of .pio folder corruption on Windows that significantly impacts development productivity, requiring frequent manual cleanup.

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 platformio.ini configuration and reproduce the release-to-debug switch on Windows from a clean .pio folder, comparing it with WSL behavior. Trace how the environment-specific .pio/libdeps directories are reused during the build; done means switching among the listed environments no longer causes missing-header errors without manual cleanup.

Written by the indexing model from the issue text.

Assessment

Tech stack
arduino, python
Domain
build-system, embedded-iot
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.