As per subject, it goes like that: Build throws error. You edit source. Run build again, and it displays old errors pointing to the old source error line which was already corrected. Why ?
It looks like that old version of source is cached some way.
Do I have to issue some sort of save / update before running build again ? What am I missing here ?
Just an aftertought, is it possible that it is expected to close every terminal screen, as they may be stacking up in old to newest order ?
I am away from the computer now so canât veryfiy that.
Terminal screen⌠do you mean the compile/build output? Thatâs only informational⌠as long as youâve saved the file after editing it, PIO should use the latest code very time.
I also havenât seen that behaviour, so thatâs new / different. When you say errors, is this in the âproblemsâ section (meaning itâs IntelliSense, and possibly not updating properly) or the âterminalâ section (meaning itâs compile output, and a problem).
Well, that even happen when I do some changes to platformio.ini.
I have added some -D switches - build still refers to the old platformio.ini.
I am probably missing something painfuly obvious.
^^^ since youâre mentioning changes to platformio.ini - which always forces a full rebuild, it sounds like the former, which whilst is annoying, does not prevent anything from working correctly, as IntelliSense is not related to the compile process, and can say that there are errors when there are none. Yes? No?
Iâve just installed PlatformIO with VSCode and the first project Iâve tried (converted from Arduino) is doing exactly this.
Had an error reported after build. Clicked the link to the code in the error. Edited it. Build reports the same error, with the old text in the error message.
Intellisense does track the changes. I even wrote a line of junk in the file, and the Build process does not even see it.
Update: After closing & opening VSCode, it does appear to be working as expected now. Will update if it happens again.
Update2: Some files work fine - changes are Built. Other files in the same project do not. Closing VSCode & reloading does seem to change things. Is VSCode caching files?
When you say âBuild reports the same errorâ, do you refer to the full log in the TERMINAL view or the error as shown in the PROBLEMS view?
And what do you mean by Build process?
Anyhow, the situation is like so:
Visual Studio Code is NOT a fully integrated development environment, and it has no plans to become one. Therefore, it loosely integrates development tools such as source code validation while typing, version control, build systems and their output etc.
As a result, IntelliSense and PlatformIOâs build system work more or less independently. Since they work on the same source code and use the same compiler settings, they should be mostly in sync, ie. all IntelliSense errors should also appear in PlatformIOâs output. (The opposite is not true as IntelliSense cannot detect linker errors.)
The PROBLEMS view is populated by messages from InelliSense and from parsing the PlatfromIO output in the TERMINAL view. Parsing is easily confused. In particular, it does not clear the old messages if you execute pio run manually in the terminal view or even in a separate terminal program. It only does so if you run via a build command (icon in status bar, action in task view etc.) from within Visual Studio Code.
To get rid of the error message, either:
build using a Build command (icon in status bar, action in task view etc.), or
I was building using the icon in the status bar, and the error was as reported in the terminal, being output during the build process. I didnât look at the problems view, just the terminalâs build output.
I was going to see if my edits were actually saved to the files on disk, but this project appears to be building without errors now, and if I make edits to the files, it now behaves as expected.
The issue seemed to appear with 2 separate files, and the corrections to those errors were only seen by the build process after closing & restarting VSCode.
This problem persists.
I edited and built the same project using the status bar icon.
The build output appears in the console, with new errors.
I commented out the errors, and re-ran the build, and the newly generated output has the same errors.
The file saved on disk has been changed, with the erroroneous code commented out.
How is the old code persisting? Surely PlatformIO calls the arduino build process passing references to the files on disk?
Update - some further information:
My project does have an additional folder called âlibsâ in the same folder as the src, with source code in it.
During the build, in .pio several temporary folders are created with variations on âlibxxxâ containing the compiled .a files.
It appears that changes in the source âlibâ files, as compared to the âlibxxxâ, are not being detected and they are not recompiled.
It does appear running a âCleanâ does delete all the temporary folders, and a following Build then compiles everything correctly.
Thanks for the investigation. Can you provide the structure of the project folder (files and directories, without .pio directory)? And can you indicate to which file youâve added the compile error for testing?