Platformio-core: First build often fails after changing platformio.ini

Created on 5 Sep 2019  路  11Comments  路  Source: platformio/platformio-core

Solution

See https://github.com/platformio/platformio-core/issues/2972

Please convert INO files to CPP https://docs.platformio.org/en/latest/faq.html#convert-arduino-file-to-c-manually


Configuration

Operating system: Windows 10

PlatformIO Version (platformio --version): 4.0.3

Platform: Arduino (ESP8266 to be exact)

Editor/IDE: VS-Code

Description of problem

When changing the platformio.ini file, and save it, a test is run to create a .ino.cpp file.
At the end of this test, the file is deleted.
If you start a build while this test has not yet finished, then the .ino.cpp file is gone by the time the compile run is ready for processing this file.

This is what happens if you don't save the file yet but just hit the 'build' task to run.
It will save all open (unsaved) files and start building.
This save triggers the test run also.

Steps to Reproduce

  1. Make changes in platformio.ini Don't save yet
  2. Start compile
  3. Compile fails, since setup() nor loop() is found
bug build system wontfix

Most helpful comment

Thanks! You gave me an idea. The issue is not linked with VS Code autosaving. The problem is that after "saving" of platformio.ini PlatformIO IDE extension rebuilds C/C++ project index. This is an issue. I will think about how to resolve it.

All 11 comments

Is this issue related to PIO Core? Do you mean that VSCode does not save automatically before build?

Well I didn't know exactly what part of PIO it should be.
It also happens with Atom, so it is not just VS code.

Steps to Reproduce

Hm, if you didn't save a file how compiler should find setup/loop?

The IDE (Atom/VScode does save the file when it is running a task.

This option is turned off by default. See
Screen Shot 2019-09-08 at 12 08 19

They are not auto saved, as in saved per interval (that would be rather annoying and resource consuming)
But as soon as you run a PIO task, the files are saved.
That's some useful feature :)
But this build fail also may happen if you save all and thus changed the platformio.ini on disk and immediately start to build.

It does generate the .ino.cpp file as a test, but also deletes it.
So by the time the core lib has been compiled, it cannot find the setup() and loop() anymore and thus fails the build.

Thanks! You gave me an idea. The issue is not linked with VS Code autosaving. The problem is that after "saving" of platformio.ini PlatformIO IDE extension rebuilds C/C++ project index. This is an issue. I will think about how to resolve it.

Just for my understanding, was this a "core" issue?

@TD-er More an issue with the platformio/platformio-vscode-ide extension. As Ivan said... when the platformio.ini is saved. the extension immediately rebuilds the C/C++ project index ... aka.... PlatformIO: IntelliSense Index Rebuild... Now, AFAIK... this issue is no more... as it 'seems' that when you bash the build button on an unsaved platformio.ini... that the rebuild happens, and then the build happens... i.e. it does appear to block or queue... Yes? No? Small furry creature from Alpha Centauri?

I reproduced this issue last time. It's only related when Arduino INO file is used. There is a race condition when PlatformIO Build System and Project Index Builder convert INO to CPP. We will work on good fix for this case.

Was this page helpful?
0 / 5 - 0 ratings