You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cleanup ExtensionContext.workspaceState when a workspace no longer exists #32461
Reacted by Arlo O'Keeffe, Eduard Kyvenko, 0x7FFFFFFFFFFFFFFF, Ben Mewburn, Thomas Peißl, Giacomo Trezzi, KamasamaK, everdrone, E. Lofgren (TiER1), Jean Desulme and 53 more
Dirk Bäumer (@dbaeumer) how do we know that a workspace no longer exists? Imho just checking for existence of the path is not enough, there may be many users that work via a remote network drive or even a mounted disk where the connection is not always there. Just going by fs.exists imho can result in bad user experience for these users.
Benjamin Pasero (@bpasero) the network drive case is an interesting case I never thought about. We could do the following: if it is a UNC path \...\ and it doesn't exist we leave the workspace storage. Same for a drive letter that doesn't exist. We could prompt the user with a list so that he could clean them manually.
Dirk Bäumer (@dbaeumer) not sure it is that easy, for example VMs can map a folder into my macOS and this folder is not there if the VM is not started. The path itself does not indicate if it is from a VM/remote or not.
Benjamin Pasero (@bpasero) I am not sure I fully understand that example. How would the storagePath and the workspace folder be layout in that case. Would the storagePath be inside the VM and the workspace folder location mounted into the VM?
Dirk Bäumer (@dbaeumer) no, the extension storage will always be on the disk where VS Code is installed (e.g. %APPDATA%). I was trying to comment on your statement:
We could do the following: if it is a UNC path ...\ and it doesn't exist we leave the workspace storage. Same for a drive letter that doesn't exist.
On Linux and macOS there are no UNC paths and there are no drive letters. Paths can come and go depending on mounts (e.g. a parallels VM started or stopped), so by just looking at the path you will not be able to find out if the path was deleted or not mounted.
After taking Benjamin Pasero (@bpasero) input into consideration it is clear that we can't simply delete workspace storage folders. So we need some UI affordance that point to large workspace storage folders and ask the user whether we should clean it up or not
Reacted by Benjamin Pasero, Arturo Linares, Álex Acuña Viera, enkay, Thomas Peißl, KamasamaK, leo, E. Lofgren (TiER1), Mathieu Darse, Lemmingh and 2 more
I'd appreciate some options to choose clean up strategies, checking if it exists is fine if you don't use network paths (maybe you could detect if it's a network mount when creating the workspace files in the first place?). If it is a network mount, perhaps just cleaning up LRU (Least Recently Used) would be fine?
I just noticed this directory is 35GB on my laptop, with some of the oldest workspaces being nearly a year old and most of them no longer existing (I tend to a roll out a new workspace per feature branch on one project I work on).
Could ExtensionContext provide a list of an extension's storagePaths? For my use case I could clean up old data by looking at modtime on extension activation.
After another desperate search to clear up some space on my laptop, I stumbled on a 36GB workspaceStorage directory which led me here. While I think that the idea of moving this data to the workplace folder makes sense in some regards, I think there is one other aspect of this to consider: the CPP-Tools extension is not relevant to 99% of my dev work, so why is it creating a 1GB file every time I open a new workspace?
Concern
If the proposal to move this data to individual workspace folders was implemented, I worry that it would be less obvious that a rogue extension was eating all my storage. In this case, I would now have 36GB of data scattered about 36 different folders. When considering standalone workspaces setup for each package in our monorepo, and repos spread between my work directory, projects directory, tinkering, etc., I would be hard to see the scale of the problem. Say what you will about having repos in so many different places, but if I were sweeping my HD to clear up space, 1GB wouldn't raise flags (that's entirely normal for node_modules), but 36GB in one folder absolutely does.
Context
I do almost exclusively JS/TS/React programming. Last summer I added PlatformIO and some other extensions to compile firmware for a 3d Printer. I have not touched a CPP file since then, and had largely forgotten about those extensions. When finding these files, my first thought was "I never installed this extension" since IIRC it was installed as a part of the PlatformIO setup process. After deleting the CPP-Tools folders, my workspaceStorage directory (going back to July 2016) is only 20.2MB.
Proposal
Would it not be better to provide some mechanism for controlling whether an extension will be initialized at all for a given workspace? CPP-Tools seems to be an egregious offender (~1GB per workspace), but might a better solution be to enable Extension Developers to register specific file types which would activate their extension?
Example
A toolkit for Extension Developers would work something like this:
Extensions can set a default enabledFiletypes property in the extension registry
When opening a workspace, any extensions with the enabledFiletypes property would be cross checked with the filetypes present in the project
If there is an intersection, enable the extension, otherwise disable it by default.
Considerations
The logic would need to handle module folders (eg: node_modules) so that a matching file does not activate the extension. This could integrate with the existing Search: Exclude and Files: Exclude settings.
The behavior must be overridable at the user and workspace configuration levels, to both "always enable" and to override the enabledFiletypes
There is merit in the idea of a warning, or automated sweep of old workspace caches; which would be much more easily implemented if this data stays centralized.
Patrick Fowler (@pdfowler) I think it should be reasonable to fill an issue in cpptools to ask them to move cache data closer to a project instead of relying on vscode. Global storage was probably worst idea ever. If ones renames a project folder and reopens it in a vscode the wasted storage is going to multiply significantly.
There is a bunch of related issue concerning moving workspaceStorage databases to local-to-project .vscode/. The devs said they won't fix it cause the vscode-cpptools extension shares workspaces across project.
It's probably good idea to consider other C/C++ tooling llike clangd.
I've had the same problem and started to develop an extension to solve this problem. Unfortunately I'm not so familiar with the VSCode API (Visualization page, user requests, unit tests, ...), deploying to the marketplace and so. Because of this the development get stucked. Maybe someone else will continue with this as base? The idea of Ryan (@slugmuffin) to present more information to the user and to ask for deletion is much better than my simple implementation. This could be a list with with the information and a check box (to delete or not delete, that's the question) for each workspace closed by common buttons for delete marked and abort.
starball (@starball5) and also Karl Schultz (@karl-lunarg) thanks for hinting this extension. Didn't know that and haven't found this while I was searching for a solution to this problem. Does exactly what I've planned for my own extension. Great!
After restoring a full backup, I realized that the vscode extensions folder consumes 5.6GB. How can it be optimized? Why is it storing all old versions?
Haven't been using VS Code for years now and can tell you: the problem went away like a charm! Just drop it boys and switch to a brighter side: Neovim. Cheers.
Reacted by Wojtek
Reacted by Nick Chevsky, ‮, Diana, Tom Thorogood, Jared Ping and Brad Durbin
Activity
bpasero commentedon Aug 15, 2017
Dirk Bäumer (@dbaeumer) how do we know that a workspace no longer exists? Imho just checking for existence of the path is not enough, there may be many users that work via a remote network drive or even a mounted disk where the connection is not always there. Just going by
fs.existsimho can result in bad user experience for these users.dbaeumer commentedon Aug 15, 2017
Benjamin Pasero (@bpasero) the network drive case is an interesting case I never thought about. We could do the following: if it is a UNC path \...\ and it doesn't exist we leave the workspace storage. Same for a drive letter that doesn't exist. We could prompt the user with a list so that he could clean them manually.
bpasero commentedon Aug 15, 2017
Dirk Bäumer (@dbaeumer) not sure it is that easy, for example VMs can map a folder into my macOS and this folder is not there if the VM is not started. The path itself does not indicate if it is from a VM/remote or not.
dbaeumer commentedon Aug 16, 2017
Benjamin Pasero (@bpasero) I am not sure I fully understand that example. How would the storagePath and the workspace folder be layout in that case. Would the storagePath be inside the VM and the workspace folder location mounted into the VM?
bpasero commentedon Aug 16, 2017
Dirk Bäumer (@dbaeumer) no, the extension storage will always be on the disk where VS Code is installed (e.g.
%APPDATA%). I was trying to comment on your statement:On Linux and macOS there are no UNC paths and there are no drive letters. Paths can come and go depending on mounts (e.g. a parallels VM started or stopped), so by just looking at the path you will not be able to find out if the path was deleted or not mounted.
dbaeumer commentedon Aug 24, 2017
After taking Benjamin Pasero (@bpasero) input into consideration it is clear that we can't simply delete workspace storage folders. So we need some UI affordance that point to large workspace storage folders and ask the user whether we should clean it up or not
//cc Erich Gamma (@egamma) Kai Maetzel (@kieferrm)
neerolyte commentedon Apr 9, 2018
I'd appreciate some options to choose clean up strategies, checking if it exists is fine if you don't use network paths (maybe you could detect if it's a network mount when creating the workspace files in the first place?). If it is a network mount, perhaps just cleaning up LRU (Least Recently Used) would be fine?
I just noticed this directory is 35GB on my laptop, with some of the oldest workspaces being nearly a year old and most of them no longer existing (I tend to a roll out a new workspace per feature branch on one project I work on).
woshichengxinxin commentedon Aug 30, 2018
cpptools takes 8GB space on my poor C disk.
bmewburn commentedon Jan 25, 2019
Could
ExtensionContextprovide a list of an extension'sstoragePaths? For my use case I could clean up old data by looking at modtime on extension activation.18 remaining items
pdfowler commentedon Mar 29, 2022
After another desperate search to clear up some space on my laptop, I stumbled on a 36GB
workspaceStoragedirectory which led me here. While I think that the idea of moving this data to the workplace folder makes sense in some regards, I think there is one other aspect of this to consider: the CPP-Tools extension is not relevant to 99% of my dev work, so why is it creating a 1GB file every time I open a new workspace?Concern
If the proposal to move this data to individual workspace folders was implemented, I worry that it would be less obvious that a rogue extension was eating all my storage. In this case, I would now have 36GB of data scattered about 36 different folders. When considering standalone workspaces setup for each package in our monorepo, and repos spread between my work directory, projects directory, tinkering, etc., I would be hard to see the scale of the problem. Say what you will about having repos in so many different places, but if I were sweeping my HD to clear up space, 1GB wouldn't raise flags (that's entirely normal for
node_modules), but 36GB in one folder absolutely does.Context
I do almost exclusively JS/TS/React programming. Last summer I added PlatformIO and some other extensions to compile firmware for a 3d Printer. I have not touched a CPP file since then, and had largely forgotten about those extensions. When finding these files, my first thought was "I never installed this extension" since IIRC it was installed as a part of the PlatformIO setup process. After deleting the CPP-Tools folders, my
workspaceStoragedirectory (going back to July 2016) is only 20.2MB.Proposal
Would it not be better to provide some mechanism for controlling whether an extension will be initialized at all for a given workspace? CPP-Tools seems to be an egregious offender (~1GB per workspace), but might a better solution be to enable Extension Developers to register specific file types which would activate their extension?
Example
A toolkit for Extension Developers would work something like this:
enabledFiletypesproperty in the extension registryenabledFiletypesproperty would be cross checked with the filetypes present in the projectConsiderations
node_modules) so that a matching file does not activate the extension. This could integrate with the existingSearch: ExcludeandFiles: Excludesettings.enabledFiletypeshinell commentedon Aug 17, 2022
Patrick Fowler (@pdfowler) I think it should be reasonable to fill an issue in cpptools to ask them to move cache data closer to a project instead of relying on vscode. Global storage was probably worst idea ever. If ones renames a project folder and reopens it in a vscode the wasted storage is going to multiply significantly.
hinell commentedon Oct 26, 2022
There is a bunch of related issue concerning moving
workspaceStoragedatabases to local-to-project.vscode/. The devs said they won't fix it cause thevscode-cpptoolsextension shares workspaces across project.It's probably good idea to consider other
C/C++tooling llikeclangd.ThirtySomething commentedon Dec 15, 2022
I've had the same problem and started to develop an extension to solve this problem. Unfortunately I'm not so familiar with the VSCode API (Visualization page, user requests, unit tests, ...), deploying to the marketplace and so. Because of this the development get stucked. Maybe someone else will continue with this as base? The idea of Ryan (@slugmuffin) to present more information to the user and to ask for deletion is much better than my simple implementation. This could be a list with with the information and a check box (to delete or not delete, that's the question) for each workspace closed by common buttons for
delete markedandabort.starball5 commentedon Mar 7, 2023
Loosely related Stack Overflow question: What are the effects of clearing the workspaceStorage folder for Visual Studio Code?
Related extension:
mehyaa.workspace-storage-cleanupkarl-lunarg commentedon Mar 15, 2023
Jochen Paul (@ThirtySomething) There's already an extension that does what you want. (https://marketplace.visualstudio.com/items?itemName=mehyaa.workspace-storage-cleanup) It puts up a list of all the workspaces and provides toggles that select/deselect workspaces based on whether or not they point to non-existent files. There's also a separate toggle for remote workspaces because the check for non-existent files doesn't work the same way. And you can select workspaces manually for deletion.
I just installed and ran it and it worked great!
Edit: I missed that starball5 mentioned the same extension. Sorry for the duplication.
ThirtySomething commentedon Mar 16, 2023
starball (@starball5) and also Karl Schultz (@karl-lunarg) thanks for hinting this extension. Didn't know that and haven't found this while I was searching for a solution to this problem. Does exactly what I've planned for my own extension. Great!
d-damien commentedon Oct 18, 2023
Cache cleaning tools should be available as CLI since bloated caches can sometimes prevent starting the GUI.
anibalsanchez commentedon Jan 22, 2024
After restoring a full backup, I realized that the vscode extensions folder consumes 5.6GB. How can it be optimized? Why is it storing all old versions?
cspence001 commentedon May 22, 2024
For macOS users replace:
~/.config/Code/User/workspaceStorage/*with:
~/Library/Application\ Support/Code/User/workspaceStorage/*hinell commentedon May 23, 2024
Haven't been using VS Code for years now and can tell you: the problem went away like a charm! Just drop it boys and switch to a brighter side: Neovim. Cheers.
woj-tek commentedon Jan 24, 2025
I just found out that my
workspaceStoragetakes 6G... honestly, even "bloated IDEA" uses less space… why this hasn't been resolved yet?!