Build compiles all source files every time


I’m using PlatformIO IDE with the mbed framework.
Everytime I run a build command, every files get compiled, even if I change nothing. All the mbed framework is compiled everytime.
If I run two times the compile command, both will compile everything, without any editing in the meantime.

What do I miss?

My platformio.ini files look like that:

platform = ststm32
board = disco_f746ng
framework = mbed
debug_tool = stlink
debug_load_mode = always
upload_protocol = stlink
build_flags =
    -I src
    -I drivers
lib_deps =
src_filter = +<*> +<../drivers>

Thanks for your help

By looking at the Debug Console, I found the following error:

*** [.pio/build/disco_f746ng/FrameworkMbed/targets/TARGET_STM/TARGET_STM32F7/device/stm32f7xx_hal_cryp_ex.o] /Users/username/src/projectname/gsboard-v2/.pio/build/disco_f746ng/FrameworkMbed/targets/TARGET_STM/TARGET_STM32F7/device/stm32f7xx_hal_cryp_ex.o: No such file or directory
FileNotFoundError: [Errno 2] No such file or directory: '/Users/username/src/projectname/gsboard-v2/.pio/build/disco_f746ng/.sconsign.py37.dblite':
  File "/Users/username/.platformio/packages/tool-scons/script/../engine/SCons/Script/", line 1374:
    _exec_main(parser, values)

And that could refer to this anomaly, as my project is quite big:

But I don’t know how to apply this config to platformIo


Please check that you use THE SAME Python interpreter for IDE and CLI. If you are on Windows, remove multiple Pythons from a system and use the latest Python 3.7. See instruction Redirecting...

So I found the file I needed to modify.

I modified the line 144 of the file .platformio/penv/lib/python3.7/site-packages/platformio/builder/
And I replaced:
env.SConsignFile( join("$BUILD_DIR", "" % (sys.version_info[0], sys.version_info[1])) )
env.SConsignFile( join("$BUILD_DIR", ".sconsign.dblite") )

And now it’s working.
I think this is a bug because the mbed framework contains many many files.

1 Like

Please post this exact thing to Issues · platformio/platformio-core · GitHub as the file originates from there (source ), and @ivankravets can have a look at it :slight_smile:

Could you add

import sys

Do you see the same Python version?

@nmathon this worked for me too, thanks !

@ivankravets print(sys.version) gives
3.7.5 (tags/v3.7.5:5c02a39a0b, Oct 15 2019, 00:11:34) [MSC v.1916 64 bit (AMD64)]
But I am not seeing the same error, the system was creating a file .sconsign.py37.dblite, no obvious error message

Why do you need a fix by @nmathon? If you see the same Python every build you should not have any problems. Please try again to repeat multiple times build process and check print(sys.version). Do yo use PlatformIO IDE for VSCode? Maybe, it uses different Python that you use in CLI.

@ivankravets For info this not fixed anymore.
I am back to full rebuild of mbed libraries at every upload.
The python verion does not change.

What else can I check ?

What is your OS? Do you use the latest PlatformIO Core + dev-platform? pio upgrade + pio update.

1 Like

Windows 10 (up to date)
I don’t know the exact version of Mbed, it was packaged with PIO (version 5 at least)
New PC installation (had the same problem on the old PC)




Could you provide a remote session under tour control to debug this issue on your machine? If yes, please write directly to @valeros and he will provide further instructions.

1 Like

I have the same issue. I have tried reinstalling pio. Very occasionally the problem does not occur.

I’m using VScode 1.42.2 from Arch community packages.

Troubleshooting says that we can use --debug=explain to see why scons thinks the project needs to be rebuilt. Where do we put it in pio?

1 Like

I just noticed that I had “Platformio-ide: Use Development PIOCore” checked in my settings, and with it unchecked the problem with building has not yet reoccurred!

@nmathon Does this work for you too?

Unfortunately, the option is already unchecked in my settings. And I still have the problem.

@ivankravets I’m on MacOS, using the latest version PlatformIO 4.3.1 too, and all my source files are compiled every time, even when I don’t make any change in the project.

Sorry, we don’t have more ideas how to reproduce this issue on our testing machines. We would be thankful if someone can provide as a remote session under your control where we can debug this issue on your machine. We can use for this non-commercial purpose

If someone willing to help us, please contact me privately here in on the forum via private message @ivankravets.

I have 2 installations of PIO + VScode , on Win8 and kubuntu 19.10. Both suffering from issue. On Linux I noticed startup warning Running Visual Studio Code on Linux

… and after fixing watch limits issue gone.
I’m curious how to implement same fix on Windows.