PIO IDE in VSCode: Please don't overwrite `extensions.json`

On a regular basis, I use the VSCode-generated .vscode/extensions.json to maintain a list of VSCode extensions relevant to the project. Every time PlatformIO updates (I think this is the trigger, I could be wrong), it overwrites the entire file with one that just recommends itself for installation. Every time I see this, I need to revert the changes in git before I make commits.

I wish this weren’t the case. I’d be perfectly happy (pleased even) if the PlatformIO IDE extension appended itself to the end of the file rather than overwriting it. Could we make this change a reality/get an explanation for why it is the way it currently is?

PlatformIO will overwrite it with the result of the template evaluation

The overwriting happens here (open with w):

So if you want a sort of “merge” of your and PIOs file, or tell it to not generate that file, I think it’s best to open a feature request in the core code: Issues · platformio/platformio-core · GitHub

Temporarily deleting C:\Users\<user>\.platformio\penv\Lib\site-packages\platformio\ide\tpls\vscode\.vscode\extensions.json.tpl will make PIO also ignore this template (since it doesn’t exist anymore)

1 Like

Ah, so that’s where the behavior comes from. But why would it be programmed to do this? It’s a rather destructive operation…

Well I also do a project re-init when my IDE starts acting up and I’m glad it recreates it from scratch :sweat_smile:. That file of yours seems to be an exemption though.

I suppose… Issue up: PIO IDE in VSCode: Please don’t overwrite `extensions.json` · Issue #3374 · platformio/platformio-core · GitHub

1 Like

Fixed in

1 Like

Fixed within 27 minutes? :open_mouth:

3 Likes

Ha-ha :laughing: We have one interesting proverb in Ukraine: “Don’t put off till tomorrow what you can do today”.

Indeed, we are so close to the final release of PIO Core 4.2. Let’s wait a few days, if there are no bug reports from users, we will release it next week.

2 Likes

Jesus christ that was a quick fix… Good on you @ivankravets for getting this change merged, I really appreciate the work ethic embodied in this.

So, I need to manually update PIO via the command line in order to update to a development release? Will this dev release then update cleanly to the proper PIO Core 4.2 release when it’s pushed soon?

2 Likes

Yes, it will be updated automatically!

2 Likes

Why is this still happening??

diff --git a/firmware/.vscode/extensions.json b/firmware/.vscode/extensions.json
index b09da17..080e70d 100644
--- a/firmware/.vscode/extensions.json
+++ b/firmware/.vscode/extensions.json
@@ -2,9 +2,9 @@
     // See http://go.microsoft.com/fwlink/?LinkId=827846
     // for the documentation about the extensions.json format
     "recommendations": [
-        "platformio.platformio-ide",
-        "gruntfuggly.todo-tree",
-        "jbenden.c-cpp-flylint",
-        "SonarSource.sonarlint-vscode",

+        "platformio.platformio-ide"
     ],
+    "unwantedRecommendations": [
+        "ms-vscode.cpptools-extension-pack"
+    ]
 }

Code.

Do you use the latest PlatformIO Core? Please click on the terminal icon on the bottom status bar and type pio system info.

I use one integrated with VScode extension.

 C:\Users\dzidm\.platformio\penv\Scripts\platformio.exe system info
--------------------------  --------------------------------------------------
PlatformIO Core             6.1.4
Python                      3.9.10-final.0
System Type                 windows_amd64
Platform                    Windows-10
File System Encoding        utf-8
Locale Encoding             cp1252
PlatformIO Core Directory   C:\Users\dzidm\.platformio
PlatformIO Core Executable  platformio.exe
Python Executable           C:\Users\dzidm\.platformio\penv\Scripts\python.exe
Global Libraries            0
Development Platforms       5
Tools & Toolchains          25
--------------------------  --------------------------------------------------

You have a broken JSON file. Please remove , from the last item in the “recommendations” list.

Ok, trailing comma was part of the problem.
The second issue was that I didn’t have "ms-vscode.cpptools-extension-pack".

Here is a version that works:

{
    // See http://go.microsoft.com/fwlink/?LinkId=827846
    // for the documentation about the extensions.json format
    "recommendations": [
        "SonarSource.sonarlint-vscode",
        "gruntfuggly.todo-tree",
        "jbenden.c-cpp-flylint",
        "platformio.platformio-ide"
    ],
    "unwantedRecommendations": [
        "ms-vscode.cpptools-extension-pack"
    ]
}

Note, that "platformio.platformio-ide" was moved to the end automatically according to the template.

Thank you