VSCode .browse.c_cpp.db in each project


I’m new here and I trying to get first experiences in getting the whole tool chain working. Currently I’m working with Microchip (Atmel) AVR controller (native not Arduino). I’m really impressed how everything works as long as you know where you have to configure everything.

  • First of all: I would like to understand the concept of a workspace is
  • Second I would like to know how I can get rid of the database file .browse.c_cpp.db, which is in each project (sub folder .vscode). For what purpose is that file and can I move it to a different location, so that this file exists only once and not in each project? The file size is ca. 70MByte. This is a lot if you consider that the remaining content requires less than some hundred kB data (mainly source and configuration files). If you consider for instance ten small projects then 700MB of database files is added on top.

Regards Andreas

  1. Workspaces are a way of being able to override some of the ‘user’ settings of VSCode which are well… workspace specific. I use it reguarly though as a way of being able to have multipile projects organised… I have related several build environments in one, have some forum test code stubs in another, etc, etc, and can switch between them as simply as opening the different workspace.

  2. The .browse.c_cpp.db file is generated by the C/C++ extension, and has all the symbols and code matching stuff that allows that intelisense code completion to work. It’s unique to every project. It does seem you can change the path though.

Thanks for the answers. Maybe my questions were not specific enough

Workspaces: is every project organized as a separate Workspace or are all projects under one Workspace. Honestly, i have issues to understand the difference between project and workspaces. E.g. there is a certain structure in each project folder to be platformio project, so with certain subfolder, certain common files etc… But, what is specific for the Workspace? Does this also result into a certain folder / file structure?0

Regarding [browse.c_cpp.db]
I have the impression that not many people complain with multi Symbol database files. Is the content basically not the same? I cannot understand why such a Symbol database has to be in every project. Really this bloats up the size of you have several projects. If a common Single database does not properly work, ok then I have to live with this. Otherwise I would recommend to store the database file only once.

Regarding workspaces, maybe this screenshot will help enlighten things.


In that one workpace, I have eight different projects. I have another workspace where I keep projects related to testing forum code snippets. I have another workspace where I have some work related code. It’s just another way to logically separate projects, and allows all of the VSCode settings to change by workspace, and even the extensions that are enabled or installed in each. It is not platformio specific, it is a VSCode thing.

With browse.c_cpp.db, it is a VSCode (or to be more accurate Micorosft C/C++ VSCode extension) thing, so it would be a matter of finding out if a shared library can be used, or is there something in the way they’ve designed it which make it not possible. Maybe Ivan can comment as to whether it’s something that needs to stay this with because of how PlatformIO works or can be improved on?

It may also be worth seeing if this setting lets you set a global path without breaking anything… File -> Preferences -> Settings and put intelli sense cache path in the search box…

Hello, sorry for late answer I was quite busy to reply just in time …
Thanks for the helpful infos regarding workspace. That is basically also my understanding. One concrete example about my folder structure:

  • Path, where all my platformio projects are hosted (I call it my “workspace”)
  • The sub folder contains my projects.

If I’m checking where the ${workspaceFolder} is pointing then it seems that this is for every project. Therefore, I do not understand why there is a separate .vscode folder in each project (which are indeed under one workspace. So I have changed the directory to the root of the project folders which should be the workspace from my point of view.

But only some cached files have been created under .vscode/ipch folder in this location - not the database file itself. So this doesn’t help me but anyway it was worth to look for it.

Maybe I have to live with this approach from VSCode even though I don’t understand why it has to be so. I understand the need for the database file for intellisense but I cannot understand the duplication of a >70MB file for every project if the contents is the same. Bloating up required project size should be avoided by a modern smart IDE.

UPDATE 2019-Mar-30: I 've got the stuff temporarily running as I would expect with the hints given in your previous reply so I changed the c_cpp_properties.json ‘browse’ section for the database file. Unfortunately the changes will be overwritten by whatever tool. The first line in this file has a warning that this file shall NOT be modified - maybe platformio handles this file.

Regards Andreas

1 Like

Yes, platformio does modify c_cpp_properties.json file (hence the warning - as a change to something like an include path would be lost in a re-write)… I was hoping that editing it through the VSCode preferences rather than manually might encourage it to use the configured setting… apparently not! :frowning_face:

${workspaceFolder} is indeed VSCode workspace specific… it really can’t be anything else as they haven’t figured out mind reading (yet!) :laughing: Unfortunately, with multi-root workspaces (i.e. a workspace with several projects in it), this, therefore, means multiple ${workspaceFolder} … so it would be better to have an absolute path rather than a relative path with the variable. This certainly is annoying… as you said… the need for the database is understandable… but really… 70MB+ for every AVR project… even a stupid ‘blinky’ one? That’s a bit much! :slightly_frowning_face: :laughing: ESP8266 ones don’t seem as bad for some reason… seem to weight in at 15MB…

I know this is rather an old thread but I just started using platformio and the browse files cause a lot of bloat. I wonder to keep disc space down have all your source code under one folder. Only have one “project” and copy the source to the one project. When you are done just close VSC/platformio and move the source code files back under your original folder. 70MB per project that’s just ridiculus.

If we remove keeping browse DB in a .vscode folder, VSCode C++ extension will spam your original VSCode installation folder.

1 Like

What about allowing "databaseFilename": "${workspaceRoot}/.vscode/.browse.c_cpp.db" to be overridden to some common path? Or is that going to spectacularly backfire?

There’s two preferences that don’t seem to be working , probably because of the c_cpp_properties.json preferences?

"C_Cpp.intelliSenseCachePath": <string>
"C_Cpp.intelliSenseCacheSize": <number>

In the issue on the VSCode github, they’ve ‘fixed’ it by moving the default intellisense path out to a common directory, but that doesn’t apply.

Being nasty to PlatformIO, and setting "databaseFilename": "C:/Users/Peter/.cpptools/.browse.c_cpp.db" with a quick 'read-onlyon a pair ofc_cpp_properties.json` files to prevent it be over-ridden seems to work fine for moving the files to a suitable external directory, and seems to properly handle multiple cache databases, as implied by the suggestion to have a single common intellisense path.

Food for thought?

Edit: I see there is an issue on the github page for that also: Lack of option to choose .browse.c_cpp.db file location · Issue #787 · platformio/platformio-vscode-ide · GitHub

1 Like

Could you file a feature request here Issues · platformio/platformio-core · GitHub ? Also, please provide a link to this discussion. Thanks!

Resolved in

Sorry, maybe I missed the solution. Is the issue solved now and If yes what ist the solution?

Regards Andreas

Go to the VSCode preferences, open the settings json, and add the two lines indicated in the comments in the issue linked. Alter the paths to your hearts content. Not that one of the VSCode C++ extension team pointed out in another issue that having the databaseFilename the same for more than one folder is a bad idea, but they haven’t implemented the necessary logic to be able to do it properly yet…


1 Like