PlatformIO: Build stops working

I’m having trouble with compiling a project. The build command will initially work and report all of the errors that it finds - no problem.

But when I try to resolve the problems, I eventually get to the point where the build icon no longer does anything. This is where progress stops and even when I remove any changes that I have made, the build command will no longer work. :grimacing:

I trust someone can tell me what I am doing wrong…

I have simple code that essentially does nothing

#include <Arduino.h>
#include <ArduinoMqttClient.h>

void setup() {
  // put your setup code here, to run once:
}

void loop() {
  // put your main code here, to run repeatedly:
}

When I try building it, it produces

 *  Executing task: C:\Users\Peter's Workshop\.platformio\penv\Scripts\platformio.exe run 

Processing esp32dev (platform: espressif32; board: esp32dev; framework: arduino)
----------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (6.1.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-arduinoespressif32 @ 3.20007.0 (2.0.7)
 - tool-esptoolpy @ 1.40500.0 (4.5.0)
 - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 33 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio\build\esp32dev\src\main.cpp.o
src/main.cpp:2:10: fatal error: ArduinoMqttClient.h: No such file or directory

***************************************************************************
* Looking for ArduinoMqttClient.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:ArduinoMqttClient.h"
* Web  > https://registry.platformio.org/search?q=header:ArduinoMqttClient.h
*
***************************************************************************

 #include <ArduinoMqttClient.h>
          ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
*** [.pio\build\esp32dev\src\main.cpp.o] Error 1

I edit the include path and get no change, so I add lib_deps to platformio.ini, as follows

; 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:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino

; Library options
lib_deps =
    arduino-libraries/ArduinoMqttClient@^0.1.7

which produces the following error

Error: Invalid 'C:\Users\Peter's Workshop\Documents\MicroProcessor Stuff\Sketches\Under Development\Tests and Trials\Sample\platformio.ini' (project configuration file): 'Source contains parsing errors: "C:\\Users\\Peter's Workshop\\Documents\\MicroProcessor Stuff\\Sketches\\Under Development\\Tests and Trials\\Sample\\platformio.ini"
        [line 16]: 'arduino-libraries/ArduinoMqttClient@^0.1.7''

and now the build icon stops working and even when I remove my platformio.ini changes, the build still does not work.

I cannot progress further. It appears there’s a formatting error in platformio.ini. Is that correct? I cannot see it.

That is strange.

I’ve just tried to add it to my lib_deps and it was downloaded with no issues.

  1. Try to install it via terminal, not using the IDE: just run pio run
  2. Paste all the contents of your platformio.ini file and all the results of the pio run command

I have previously downloaded the library for an earlier project. Does that matter?

I’m not at my worksation right now. I’ll try your terminal suggestion when I get back.

OK dvd, thanks for the advice. Unfortunately I get the following error messages.

and my platformio.ini is …

; 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:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino

lib_deps = 
    arduino-libraries/ArduinoMqttClient@^0.1.7
    

Did you try this in your other user account too that doesn’t have ' in it?

OK Max I logged into my other ‘test’ account that doesnt have the ’ in it. I created a project exactly the same as described above and added the line to main.cpp

#Include <ArduinoMqttClient.h>

Build and pio run commands both failed with file not found for the ArduinoMqttClient library - as expected.
After platformio.ini was edited to include

lib_deps = 
    arduino-libraries/ArduinoMqttClient@^0.1.7

…everything worked as it should, with the library being downloaded and installed. Great :grinning:

This aligns with my experience in my normal user account, where I had been sucessfully working on a project for the past month which included ArduinMqttClient. It is only after I created a second project that things stopped working. So I repeated those steps by creating a second project in the test user account.

This second project is identical to the first, as described in the original post.

And it fails to build as well. For whatever reason it cannot find the ArduinMqttClient library.
Here’s the error message…

  Executing task: C:\Users\Piouser\.platformio\penv\Scripts\platformio.exe run 

Warning! Ignore unknown configuration option `lib deps` in section [env:esp32dev]
Processing esp32dev (platform: espressif32; board: esp32dev; framework: arduino)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (6.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-arduinoespressif32 @ 3.20008.0 (2.0.8)
 - tool-esptoolpy @ 1.40501.0 (4.5.1)
 - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 33 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio\build\esp32dev\src\main.cpp.o
Compiling .pio\build\esp32dev\FrameworkArduino\Print.cpp.o
Compiling .pio\build\esp32dev\FrameworkArduino\Stream.cpp.o
Compiling .pio\build\esp32dev\FrameworkArduino\StreamString.cpp.o
src/main.cpp:2:10: fatal error: ArduinoMqttClient.h: No such file or directory

***************************************************************************
* Looking for ArduinoMqttClient.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:ArduinoMqttClient.h"
* Web  > https://registry.platformio.org/search?q=header:ArduinoMqttClient.h
*
***************************************************************************

 #include <ArduinoMqttClient.h>
          ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
*** [.pio\build\esp32dev\src\main.cpp.o] Error 1
================================================================================================ [FAILED] Took 6.01 seconds ================================================================================================

I am puzzled by the

Warning! Ignore unknown configuration option lib deps``

What the heck does that mean when platformio.ini is identical to the first project where the same lib deps works! :grimacing:

Anyway, this all leads me to conclude that I must have to do something different for second or subsequent projects that use previously downloaded libraries?

Am I correct?

Unfortunately I have not had an opportiunity to research this yet.

Warning! Ignore unknown configuration option lib deps in section [env:esp32dev]

Looks like there is missing an underscore lib deps vs lib_deps

OK thanks sivar2311.

This corrected the problem in my test user account and the library was installed.

OK so back to my main user account and the original problem…

None of the icons at the bottom work and one is always “loading”
image

And if I use the terminal command pio run, I get the following error, even though the lib_deps is commented out!

'Source contains parsing errors: "C:\\Users\\Peter's Workshop\\Documents\\MicroProcessor Stuff\\Sketches\\Under Development\\Tests and Trials\\Sample\\platformio.ini"
        [line 16]: 'arduino-libraries/ArduinoMqttClient@^0.1.7''

Why is there a parsing error when the “offending” line is commented out?

Figuring that I have some kind of error in platformio.ini, I copied in a working platformio.ini from another project and now I have a dependency graph containing libraries that my code doesnt contain.

Dependency Graph
|-- RFM69 @ 1.5.2
|-- ArduinoMqttClient @ 0.1.7
|-- ArduinoJson @ 6.21.2
|-- WiFi @ 2.0.0

Even after I removed the unnecessary lib_deps, this graph doesnt change. How is this dependency graph determined?

I seem to be digging myself a deeper hole… :face_exhaling:

After fixing the error in the test account (lip deps vs lib_deps) the project is 100% identical to the project in the main account.

Since the error still occurs in the main account, it is now clearly proven that the cause is the special character in the name of the main account.

Solution: Use an account name without special characters.

What you say makes sense, except that I’ve been using VS Code & platformio successfully for the past month or so in my main account. For whatever reason, I cannot get my second project to “behave”.

And sure, I can use a different account without the special character, but that would mean a significant change to years of other work. While it is a possible ‘solution’, it is not a welcome one.

Thanks to all your input, problem solved…

  1. Replaced platformio.ini with one from another project. This seems to cause platformIO to reconfigure the project and update metadata
  2. Executed ‘pio pkg uninstall’ to get rid of project libraries
  3. Edited platformio.ini to remove any non required lib_deps from the other project
  4. Set the environment switcher to the default option in the dropdown box. No idea why this was forever ‘loading’, but this action seems to have made the build command respond again

This has brought everything back to normal and I can finally get back to my project. :slightly_smiling_face:
Also proves that the ’ character in the account name is NOT a problem.