// file: $HOME/.config/Code/User/workspaceStorage/xxxxxxxxxxxxxxhash/workspace.json
{
"folder": "file:///path/to/projects/2021/foo/project-name-fork"
}
The above is the only way that VS Code currently associates workspace cache with a specific project residing in the folder: .....
Once the project's folder path gets renamed VS Code loses its reference to the project cache. Upon launching the cache gets rebuilt from scratch once again (ignoring the previous one). If repeated for several times the cache will grow enormously, wasting the startup-time and HDD storage space. C/C++ projects will turn into a storage killer (see related issues below).
Discovery
I got a C++ project that got indexed (including dependencies) multiple times. Later I've moved it into another place so it got indexed once again. The same thing happened to a whole range of other C++ projects and forks I have. I ended up with having a significant amount of gigabytes wasted. 😑
Steps to Reproduce:
Assuming you are using Linux-based OS and zsh/bash.
- Install C/C++ tools extension
- Get any
C/C++ project: e.g.
$ git clone --depth 1 --no-tags https://github.com/madler/zlib /tmp/zlib-0
- Remember the number of dirs in
.../workspaceStorage, like so:
$ dir -d $HOME/.config/Code/User/workspaceStorage/* | wc -l
- Open in VS Code, wait until cache gets indexed, close VS Code, rename the folder, open it up once again
$ code /tmp/zlib-0
$ mv /tmp/zlib-0 /tmp/zlib-1
$ code /tmp/zlib-1
- Repeat the last 2 steps and see the number of folders in
.../workspaceStorage growing
Solutions proposal
- Make it configurable so one can keep cache in the
.vscode folder
- Somehow mark the workspace (e.g. by a cookie) and keep its value both inside
workspace.json and .vscode, making the cache a workspace-path-independent
- Regularly clean stale caches - should be very cheap to implement and maintain
Workaround
As a temporarily solution I've made a simple bash script to audit cache files, checkout: code.workspaces.cache.filter
Versions
- VS Code Version: 1.60.2 and earlier
- OS Version: Kubuntu 20.04 - Kubuntu 21.04 / x64
Extensions
- C/C++ tools [v1.6.0] - Not a culprit in this case for sure
Related issues
The above is the only way that VS Code currently associates workspace cache with a specific project residing in the
folder: .....Once the project's folder path gets renamed VS Code loses its reference to the project cache. Upon launching the cache gets rebuilt from scratch once again (ignoring the previous one). If repeated for several times the cache will grow enormously, wasting the startup-time and HDD storage space.
C/C++projects will turn into a storage killer (see related issues below).Discovery
I got a
C++project that got indexed (including dependencies) multiple times. Later I've moved it into another place so it got indexed once again. The same thing happened to a whole range of otherC++projects and forks I have. I ended up with having a significant amount of gigabytes wasted. 😑Steps to Reproduce:
Assuming you are using Linux-based OS and
zsh/bash.C/C++project: e.g.$ git clone --depth 1 --no-tags https://github.com/madler/zlib /tmp/zlib-0.../workspaceStorage, like so:$ dir -d $HOME/.config/Code/User/workspaceStorage/* | wc -l$ code /tmp/zlib-0$ mv /tmp/zlib-0 /tmp/zlib-1$ code /tmp/zlib-1.../workspaceStoragegrowingSolutions proposal
.vscodefolderworkspace.jsonand.vscode, making the cache a workspace-path-independentWorkaround
As a temporarily solution I've made a simple bash script to audit cache files, checkout: code.workspaces.cache.filter
Versions
Extensions
Related issues