I have added ArduinoJson to the lib_deps section of my platformio.ini file, however when I compile, I get the following error:
from .pio\libdeps\nanoatmega328\ArduinoJson_ID64\src/ArduinoJson.h:9,
from src\main.cpp:109:
.pio\libdeps\nanoatmega328\ArduinoJson_ID64\src/ArduinoJson/Array/…/Variant/…/Misc/…/Strings/…/Memory/…/Variant/…/Polyfills/type_traits.hpp:7:39: fatal error: type_traits/conditional.hpp: No such file or directory
compilation terminated.
*** [.pio\build\nanoatmega328\src\main.cpp.o] Error 1
My setup: PlatformIO in Visual Studio Code, running on Windows 10.
By the way, I have tried uninstalling all libraries from PlatformIO home under the project, then reinstalling them. I get the same problem.
Here is the compile error in full. This is the compile error for the minimal example in this post, different to the error I posted before, because I removed all the code in main.cpp.
compilation terminated.
*** [.pio\build\nanoatmega328\lib035\LiquidCrystal_ID136\I2CIO.cpp.o] Error 1
In file included from .pio\libdeps\nanoatmega328\LiquidCrystal_ID136\LiquidCrystal_I2C_ByVac.cpp:46:0:
.pio\libdeps\nanoatmega328\LiquidCrystal_ID136\LiquidCrystal_I2C_ByVac.h:56:21: fatal error: Wire.h: No such file or directory
Looking for Wire.h dependency? Check our library registry!
compilation terminated.
*** [.pio\build\nanoatmega328\lib035\LiquidCrystal_ID136\LiquidCrystal_I2C_ByVac.cpp.o] Error 1
============================================================================ [ERROR] Took 11.81 seconds ============================================================================
The terminal process terminated with exit code: 1
Without including it (neither in main.cpp nor as an explicit dependency in platformio.ini), it fails to compile (.pio\libdeps\nanoatmega328\LiquidCrystal_ID136\I2CIO.cpp:54:21: fatal error: Wire.h: No such file or directory) because the dependency graph is incorrect:
I can reproduce your bug. It’s indeed related to the path length.
My first attempt on Windows was ok: it compiled. Then I moved the project to a location with a longer path and now I get the same error as well.
So the solution is: Move your project to a location with a short path.
And possibly open an issue for the ArduinoJson library to have them change their includes such that the path is shorter. It should be too difficult to prevent paths like:
As for the Wire dependency, you either need to explicitly include it in main.cpp or switch the LDF mode to chain+, as Wire.h is hidden under a preprocessor condition.
lib_ldf_mode = deep actually … I thought chain+ would work also, but it seems I2CIO.h isn’t in the direct include chain(?), hence failed miserably. I was surprised though that it didn’t need deep+ because of the preprocessor macro …
We spent 2 days understanding an error similar to the initial post and, thanks to this post we got a clue of what was going on.
In file included from .pio/libdeps/MB-DEV/ArduinoJson_ID64/src/ArduinoJson/Array/../Variant/../Misc/../Strings/../Memory/../Variant/VariantSlot.hpp:8:0,
from .pio/libdeps/MB-DEV/ArduinoJson_ID64/src/ArduinoJson/Array/../Variant/../Misc/../Strings/../Memory/MemoryPool.hpp:9,
from .pio/libdeps/MB-DEV/ArduinoJson_ID64/src/ArduinoJson/Array/../Variant/../Misc/../Strings/StringAdapters.hpp:7,
from .pio/libdeps/MB-DEV/ArduinoJson_ID64/src/ArduinoJson/Array/../Variant/../Misc/SerializedValue.hpp:7,
from .pio/libdeps/MB-DEV/ArduinoJson_ID64/src/ArduinoJson/Array/../Variant/VariantData.hpp:7,
from .pio/libdeps/MB-DEV/ArduinoJson_ID64/src/ArduinoJson/Array/ArrayRef.hpp:7,
from .pio/libdeps/MB-DEV/ArduinoJson_ID64/src/ArduinoJson.hpp:17,
from .pio/libdeps/MB-DEV/ArduinoJson_ID64/src/ArduinoJson.h:9,
from src\config/all.h:14,
from src\mbox.cpp:6:
.pio/libdeps/MB-DEV/ArduinoJson_ID64/src/ArduinoJson/Array/../Variant/../Misc/../Strings/../Memory/../Variant/../Polyfills/type_traits.hpp:7:39: fatal error: type_traits/conditional.hpp: No such file or directory
compilation terminated
I moved the project to desktop ( short path) and then it compiled OK.
The author of ArduinoJson was very responsive and has quickly changed the include paths (from relative to absolute). With the latest version (6.2.0) the problem should no longer occur.