No such file or directory "Wifi.h and WiFiClientSecure.h" with Chain+

I am trying to add WebSocket to my ESP32 project, but unfortunately the compiler fails. Following is the error message I get:

Indexing .pio\build\esp32_dev\libc94\libArduinoJson.a
Compiling .pio\build\esp32_dev\lib748\FS\FS.cpp.o
Compiling .pio\build\esp32_dev\lib748\FS\vfs_api.cpp.o
In file included from .pio/libdeps/esp32_dev/WebSockets/src/WebSocketsClient.h:28:0,
from include/websocket/websocket_client.hpp:3,
from src/websocket_client.cpp:1:
.pio/libdeps/esp32_dev/WebSockets/src/WebSockets.h:190:30: fatal error: WiFiClientSecure.h: No such file or directory

.pio/libdeps/esp32_dev/WebSockets/src/WebSockets.h:189:18: fatal error: WiFi.h: No such file or directory

I am using PlatformIO IDE, below is my platformio.ini (the important part):

framework = arduino
platform = espressif32
board = esp32dev
platform_packages = 
	; Uses new tool chain with a non-released Arduino package to be able to compile with C++17 (C++17 may become the default in the future, therefore this may be soon not necessary).
build_unflags =
	-fno-exceptions ; Removes the default exceptions disabling flag.
build_flags =
lib_ldf_mode = chain+
lib_deps =
        ; Here I am using the not-released version, because I need a fix for ESP32.

Could anyone please help me to get it compiling? I am not sure what is wrong, because my project compiles as long as I do not add WebSocket library to it.


Well, I have a new finding, changing lib_ldf_mode from chain+ to chain makes the project compiles. What is going wrong here? I need to use chain+. I believe this used to work in my ESP8266 projects.

Hm chain+ should work if it correctly evaluates stuff.

Does this happen with the latest core version to? (CLI and pio upgrade --dev).

If yes, please file a bug in Issues · platformio/platformio-core · GitHub with also a minimal code exampel to reproduce the issue.

The flow should be

It’s via two macros but it should be able to detect it – if not it’s a point of improvement and a bug report is needed per above as said.

Exactly, but unfortunately it does not (even after pio upgrade --dev). Then I am gonna report a bug.

Thank you Max!


I reported the bug here: