[ESP-IDF ESP32] Menuconfig fails due to 'unknown option "rsource" '

Hi all!

I’ve encountered a strange error with the menuconfig task (pio run -t menuconfig), where it fails to execute with the following error (full logs at the end):

%userprofile%/.platformio/packages/framework-espidf/components/esp_hw_support/Kconfig:17: syntax error
%userprofile%/.platformio/packages/framework-espidf/components/esp_hw_support/Kconfig:16: unknown option "rsource

Deleting .platformio/packages/framework-espidf and restarting VSCode appears to fix it, but it’s still a highly frustrating bug. Do older, wiser heads than mine have any suggestions, or should I open a bug report in the repo?

To reproduce, I merely need to restart VSCode. Sometimes even just adding a library will break it. [EDIT:] Running menuconfig more than once also breaks it now.
Full log (user profile path redacted):

$ pio run -t menuconfig
Processing defaults (platform: espressif32; board: esp32dev; framework: espidf)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (5.2.0) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-espidf @ 3.40402.0 (4.4.2)
 - tool-cmake @ 3.16.4
 - tool-esptoolpy @ 1.40201.0 (4.2.1)
 - tool-idf @ 1.0.1
 - tool-mconf @ 1.4060000.20190628 (406.0.0)
 - tool-ninja @ 1.9.0
 - toolchain-esp32ulp @ 1.22851.191205 (2.28.51)
 - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch3
Reading CMake configuration...
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Running menuconfig...
[0/1] cmd.exe /C "cd /D %userprofile%\OneDrive\Documents\VSCode_Projects\ESP32_RTK\.pio\build\defaults &...ENV_FPGA= --output config %userprofile%/OneDrive/Documents/VSCode_Projects/ESP32_RTK/sdkconfig.defaults"Loading defaults file %userprofile%/OneDrive/Documents/VSCode_Projects/ESP32_RTK/sdkconfig.defaults...
%userprofile%/.platformio/packages/framework-espidf/Kconfig:11:warning: environment variable IDF_ENV_FPGA undefined
%userprofile%/.platformio/packages/framework-espidf/components/esp_hw_support/Kconfig:17: syntax error
%userprofile%/.platformio/packages/framework-espidf/components/esp_hw_support/Kconfig:16: unknown option "rsource"
FAILED: CMakeFiles/menuconfig
cmd.exe /C "cd /D %userprofile%\OneDrive\Documents\VSCode_Projects\ESP32_RTK\.pio\build\defaults && %userprofile%\.platformio\penv\Scripts\python.exe %userprofile%/.platformio/packages/framework-espidf/tools/kconfig_new/prepare_kconfig_files.py --env-file %userprofile%/OneDrive/Documents/VSCode_Projects/ESP32_RTK/.pio/build/defaults/config.env && %userprofile%\.platformio\penv\Scripts\python.exe %userprofile%/.platformio/packages/framework-espidf/tools/kconfig_new/confgen.py --kconfig %userprofile%/.platformio/packages/framework-espidf/Kconfig --sdkconfig-rename %userprofile%/.platformio/packages/framework-espidf/sdkconfig.rename --config %userprofile%/OneDrive/Documents/VSCode_Projects/ESP32_RTK/sdkconfig.defaults --defaults %userprofile%/OneDrive/Documents/VSCode_Projects/ESP32_RTK/sdkconfig.defaults --env-file %userprofile%/OneDrive/Documents/VSCode_Projects/ESP32_RTK/.pio/build/defaults/config.env --env IDF_TARGET=esp32 --env IDF_ENV_FPGA= --dont-write-deprecated --output config %userprofile%/OneDrive/Documents/VSCode_Projects/ESP32_RTK/sdkconfig.defaults && %userprofile%\.platformio\packages\tool-cmake\bin\cmake.exe -E env COMPONENT_KCONFIGS_SOURCE_FILE=%userprofile%/OneDrive/Documents/VSCode_Projects/ESP32_RTK/.pio/build/defaults/kconfigs.in COMPONENT_KCONFIGS_PROJBUILD_SOURCE_FILE=%userprofile%/OneDrive/Documents/VSCode_Projects/ESP32_RTK/.pio/build/defaults/kconfigs_projbuild.in IDF_CMAKE=y KCONFIG_CONFIG=%userprofile%/OneDrive/Documents/VSCode_Projects/ESP32_RTK/sdkconfig.defaults IDF_TARGET=esp32 IDF_ENV_FPGA= "C:/Program Files/Git/usr/bin/winpty.exe" "%userprofile%/.platformio/packages/tool-mconf/mconf-idf.exe" %userprofile%/.platformio/packages/framework-espidf/Kconfig && %userprofile%\.platformio\penv\Scripts\python.exe %userprofile%/.platformio/packages/framework-espidf/tools/kconfig_new/confgen.py --kconfig %userprofile%/.platformio/packages/framework-espidf/Kconfig --sdkconfig-rename %userprofile%/.platformio/packages/framework-espidf/sdkconfig.rename --config %userprofile%/OneDrive/Documents/VSCode_Projects/ESP32_RTK/sdkconfig.defaults --defaults %userprofile%/OneDrive/Documents/VSCode_Projects/ESP32_RTK/sdkconfig.defaults --env-file %userprofile%/OneDrive/Documents/VSCode_Projects/ESP32_RTK/.pio/build/defaults/config.env --env IDF_TARGET=esp32 --env IDF_ENV_FPGA= --output config %userprofile%/OneDrive/Documents/VSCode_Projects/ESP32_RTK/sdkconfig.defaults"
ninja: build stopped: subcommand failed.
Error: Couldn't execute 'menuconfig' target.
scons: *** [menuconfig] Explicit exit, status 1

platformio.ini:

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env]
platform = espressif32
board = esp32dev
framework = espidf
upload_port = COM4
monitor_port = COM4
upload_speed = 921600
monitor_speed = 115200
monitor_filters = esp32_exception_decoder
board_build.partitions = partitions.csv
board_build.filesystem = littlefs
build_unflags = -Werror=all

[env:defaults]

[EDIT 2]: It appears that the issue is in the project folder, not %userprofile%/.platformio. Performing a diff on the framework before and after menuconfig works shows no change. However, git tracking .pio (while menuconfig is open) and then reverting fixes menuconfig. The files only appear to change after menuconfig exits.

After running menuconfig once and exiting, only the sdkconfig.defaults (see my environment name) and a .ninja_log file are modified. However, after discarding these changes, menuconfig fails to run. This failure leaves a whole lot of changes - build.ninja, CMakeCache.txt, compile_commands.json, and head-ref are all changed. Additionally, target, codemodel, and index files are all replaced with a new one containing a different hash in the filename. Reverting these changes fixes menuconfig.

[YET ANOTHER EDIT]: Moved to PIO IDE because I accidentally posted in General instead.

Did you ever sole this?

Yes, but I can’t remember (and am not sure) how. I believe the project itself was corrupted. In the end I believe I deleted %userprofile%/.pio, let PIO reinstall itself (and ESP-IDF), and created a new project and that fixed it. It’s also possible that an update to ESP-IDF fixed it, so make sure your framework is up to date.

i had been having a tustle with VSCode to get espidf working, so I expect I’d ended up in a funny state. A simple restart solved it (for now)

thanks