Can not get c_cpp_properties.json to update in VS Code

I’m new to this, but I think I have the basics. The .ini and python scripts are what will configure intellisense in VS Code, that is set up with the c_cpp_properties.json file, which will update on open and on manually rebuilding with the command among other times I don’t know about.

I deleted the c_cpp file because it was wrong and I was seeing how this all works. Now even after putting it back, I can’t seem to get it to update. I can open/reopen, manually run the command, change params, nothing.

My ini is:

description = Application
src_dir = ./src
include_dir = ./inc
lib_dir = ./lib

platform = ststm32
board = nucleo_h743zi

I’ve tried all I can think of. I used full path (which I don’t want), I saw an old issue with lower and uppercase drive letters in windows, tried that too.

I’m stuck. Help?

EDIT: I checked the existing file, I have full permissions, and I appear to be the owner. No difference if I open as admin

Well all except the include_dir are already the defaults.

What happens when you delete the .vscode folder of the project, then open a CLI and execute

pio init --ide=vscode


Hmm, yes. That fixes it once, but if I change the directories to something else the same thing happens again. Nothing will seem to update that json file now, short of pio init --ide=vscode.

So now I have a work-around but not a solution, or even a cause.

After changing the platformio.ini file, saving it, waiting a bit until the “Reload tasks” in the VSCode taskbar is gone, it does not show the changes? Also if you Ctrl+Shift+P → Rebuild Intellisense?

Do you have multiple projects / workspaces open in VSCode?

I’ve never seen a Reload Tasks dialog/toast/notification anywhere. I see the extension setting ““platformio-ide.autoRebuildAutocompleteIndex”: true” but I can make changes to the ini and nothing seems to happen.

No other workspaces open.

I’ve used CTRL+SHIFT+P to rebuild a lot, that’s how I realized it was broken.

EDIT: I did just notice under the PIO extension I have an uncaught exception that might be relevant: *Cannot read properties of undefined (reading 'isCancellationRequested')*

Solved… Somehow.

After days of not working. It does now. I had some other trouble with some extensions, so I’m guessing that I had a conflict somewhere. I also updated win10 to 10.0.19044 Build 19044 but I don’t think that would have done it.

If you find yourself with this problem, try going to HELP >> Toggle Developer Tools >> Console, clear the console, and press CTRL + SHIFT + P to open the prompt and execute PlatformIO: Rebuild IntelliSense Index. Select it and check the console.

There should be a queuing entry and a execute entry. The actual command is python -m platformio -c vscode project init --ide vscode.

1 Like

Hey @slowro,
I have the exact same problem, but no matter what I reinstall I can’t get rid of Cannot read properties of undefined (reading 'isCancellationRequested') and Could not fetch project targets for 'esp32-idf' environment and finally a fatal: not a git repository (or any of the parent directories): .git. So no intellisense.
Do you or anybody else have a solution?

I think I’ve seen this error if the projectfolder is in a git repo (or once of the parent folders in its path is a git repo) but the repo itself has no commits. (Which is fixed by creating a commit)

I’m on a fresh fork of EspHome, I’ll check what happens if I commit something

Here’s a workaround in case someone find it useful:

  1. I first created the folder .temp and this error (in the vscode devtools) went away:
    fatal: not a git repository (or any of the parent directories): .git

This is EspHome specific: But then it started complaining that it cannot import esptools
ModuleNotFoundError: No module named 'esptool':
2. So I searched a bit in the python scripts and found that there is a modifyier to use esptools as a subprocess (call the CLI directly, I think). But I don’t know how to set env vars for vscode extensions, to this file:
I added this line:
os.environ.setdefault("ESPHOME_USE_SUBPROCESS", "1")
right below import os
3. And now Intellisense seems to be working correctly and I get no errors in the console (see pic)

4. Now if I remove that line and reload, the error appears again, but intellisense still works! So it may be the case that it is broken, but ppl that already have some generated files set up don’t notice.

Here’s a better way of fixing it:

cd esphome_root_folder
mkdir .temp
source ~/.platformio/penv/bin/activate
pip install esptool
# reload vscode, et voilá