Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup ExtensionContext.workspaceState when a workspace no longer exists #32461

Open
dbaeumer opened this issue Aug 14, 2017 · 38 comments
Open
Assignees
Labels
feature-request Request for new features or functionality workbench-state UI state across restarts
Milestone

Comments

@dbaeumer
Copy link
Member

dbaeumer commented Aug 14, 2017

No description provided.

@dbaeumer dbaeumer added the feature-request Request for new features or functionality label Aug 14, 2017
@dbaeumer dbaeumer added this to the August 2017 milestone Aug 14, 2017
@dbaeumer dbaeumer self-assigned this Aug 14, 2017
@bpasero
Copy link
Member

bpasero commented Aug 15, 2017

@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.

@dbaeumer
Copy link
Member Author

@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
Copy link
Member

bpasero commented Aug 15, 2017

@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
Copy link
Member Author

@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
Copy link
Member

bpasero commented Aug 16, 2017

@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.

@dbaeumer
Copy link
Member Author

After taking @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 @egamma @kieferrm

@neerolyte
Copy link

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
Copy link

cpptools takes 8GB space on my poor C disk.

@bmewburn
Copy link

bmewburn commented Jan 25, 2019

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.

@dbaeumer
Copy link
Member Author

@bmewburn this is actually a good idea. However it could still lead to disk space consumption if an extension does nothing.

@KamasamaK
Copy link

What approach should one take to even manually clean up ExtensionContext.workspaceState? From what I can see, there is no way to just clear it. It appears that assigning undefined works if you know the key, but there is no way to see what keys exists.

@wonbyte
Copy link

wonbyte commented Mar 25, 2019

I removed a bunch of java plugins but I can still see these extension leftovers

/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/b7dc2c0ef964078613f7df57fca6c06b/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.core.runtime
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/b7dc2c0ef964078613f7df57fca6c06b/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.core.resources
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/b7dc2c0ef964078613f7df57fca6c06b/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.core.resources/.projects/jdt.ls-java-project/org.eclipse.jdt.core
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/b7dc2c0ef964078613f7df57fca6c06b/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.m2e.core
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/b7dc2c0ef964078613f7df57fca6c06b/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.debug.core
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/b7dc2c0ef964078613f7df57fca6c06b/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.jdt.core
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/b7dc2c0ef964078613f7df57fca6c06b/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.jdt.launching
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/b7dc2c0ef964078613f7df57fca6c06b/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.jdt.ls.core
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/b7dc2c0ef964078613f7df57fca6c06b/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.buildship.core
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/e4e256961bd10914f8744c86f7a9e113/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.core.runtime
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/e4e256961bd10914f8744c86f7a9e113/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.core.resources
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/e4e256961bd10914f8744c86f7a9e113/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.core.resources/.projects/jdt.ls-java-project/org.eclipse.jdt.core
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/e4e256961bd10914f8744c86f7a9e113/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.m2e.core
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/e4e256961bd10914f8744c86f7a9e113/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.debug.core
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/e4e256961bd10914f8744c86f7a9e113/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.jdt.core
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/e4e256961bd10914f8744c86f7a9e113/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.jdt.launching
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/e4e256961bd10914f8744c86f7a9e113/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.jdt.ls.core
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/e4e256961bd10914f8744c86f7a9e113/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.buildship.core
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/ea52923df5070fffee6594dcde143e14/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.core.runtime
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/ea52923df5070fffee6594dcde143e14/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.core.resources
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/ea52923df5070fffee6594dcde143e14/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.core.resources/.projects/jdt.ls-java-project/org.eclipse.jdt.core
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/ea52923df5070fffee6594dcde143e14/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.m2e.core
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/ea52923df5070fffee6594dcde143e14/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.debug.core
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/ea52923df5070fffee6594dcde143e14/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.jdt.core
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/ea52923df5070fffee6594dcde143e14/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.jdt.launching
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/ea52923df5070fffee6594dcde143e14/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.jdt.ls.core
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/ea52923df5070fffee6594dcde143e14/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.buildship.core
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/0a3063ce2c8672fecdfb338f799919e9/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.core.runtime
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/0a3063ce2c8672fecdfb338f799919e9/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.core.resources
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/0a3063ce2c8672fecdfb338f799919e9/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.core.resources/.projects/jdt.ls-java-project/org.eclipse.jdt.core
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/0a3063ce2c8672fecdfb338f799919e9/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.m2e.core
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/0a3063ce2c8672fecdfb338f799919e9/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.debug.core
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/0a3063ce2c8672fecdfb338f799919e9/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.jdt.core
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/0a3063ce2c8672fecdfb338f799919e9/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.jdt.launching
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/0a3063ce2c8672fecdfb338f799919e9/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.jdt.ls.core
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/0a3063ce2c8672fecdfb338f799919e9/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.buildship.core
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/4a03b7b375814febfae0ee6c47f7f545/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.core.runtime
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/4a03b7b375814febfae0ee6c47f7f545/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.core.resources
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/4a03b7b375814febfae0ee6c47f7f545/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.core.resources/.projects/jdt.ls-java-project/org.eclipse.jdt.core
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/4a03b7b375814febfae0ee6c47f7f545/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.m2e.core
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/4a03b7b375814febfae0ee6c47f7f545/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.debug.core
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/4a03b7b375814febfae0ee6c47f7f545/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.jdt.core
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/4a03b7b375814febfae0ee6c47f7f545/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.jdt.launching
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/4a03b7b375814febfae0ee6c47f7f545/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.jdt.ls.core
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/4a03b7b375814febfae0ee6c47f7f545/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.buildship.core
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/7f121031a7ce28a16f4ef61504239bf9/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.core.runtime
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/7f121031a7ce28a16f4ef61504239bf9/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.core.resources
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/7f121031a7ce28a16f4ef61504239bf9/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.core.resources/.projects/jdt.ls-java-project/org.eclipse.jdt.core
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/7f121031a7ce28a16f4ef61504239bf9/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.m2e.core
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/7f121031a7ce28a16f4ef61504239bf9/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.debug.core
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/7f121031a7ce28a16f4ef61504239bf9/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.jdt.core
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/7f121031a7ce28a16f4ef61504239bf9/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.jdt.launching
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/7f121031a7ce28a16f4ef61504239bf9/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.jdt.ls.core
/Users/gsieran/Library/Application Support/Code/User/workspaceStorage/7f121031a7ce28a16f4ef61504239bf9/redhat.java/jdt_ws/.metadata/.plugins/org.eclipse.buildship.core

Can I manually delete these folders? Will that cause any issues with Code?

@busticated
Copy link

seems related to #35006

@wonbyte
Copy link

wonbyte commented Mar 28, 2019

I may be wrong but #35006 seems like something for extension authors? I'm curious since i already uninstalled the redhat.java plugins if I can manually delete the above without causing any issues in Vs Code. It does not seem that the redhat.java plugins fully cleaned themselves up after uninstall.

@vgottardi
Copy link

How about storing workspaceStorage in the workspace folder instead of the user folder? This way, deleting (or unmounting) the workspace folder will automatically clear the space.
[I had .config/Code/User/workspaceStorage/fbf0af652eb1ee45193948d8b9186f2d/ms-vscode.cpptools taking 18.3GB. Was it still useful? No way to know.]

@3v1n0
Copy link

3v1n0 commented Jan 21, 2020

FYI, under linux (and I suppose would work in OSX too) I'm cleaning up the workspace folders pointing non-existing locations with this inline script:

for i in ~/.config/Code/User/workspaceStorage/*; do if [ -f $i/workspace.json ]; then folder="$(python3 -c "import sys, json; print(json.load(open(sys.argv[1], 'r'))['folder'])" $i/workspace.json 2>/dev/null | sed 's#^file://##;s/+/ /g;s/%\(..\)/\\x\1/g;')"; if [ -n "$folder" ] && [ ! -d "$folder" ]; then echo "Removing workspace $(basename $i) for deleted folder $folder of size $(du -sh $i|cut -f1)"; rm -rfv "$i"; fi; fi; done

You can find it somewhat more readable in this gist.

@fvaleri
Copy link

fvaleri commented Jan 4, 2021

We still have this issue. Today my backup tool was insanely slow and the reason was that I had 70 GB of workspaceStorage in my home directory! Do we have any solution for this issue? I really do not want to add a cleanup script.

@slugmuffin
Copy link

Would it be possible to add a window clean up past workspaces and prompt the user for input / selection.
I'd like to see a table of all workspaces, last date used and disk spaced used allowing any to be selected for removal.

There could also be a "wizard" or prompt suggesting which might worth clearing:
"VSCode workspace pointing to 'X' hasn't been used for 'Y days' taking 'ZMB' of disk space. Would you like to remove it?"

@dbaeumer
Copy link
Member Author

@slugmuffin agree that this would be the right way to go.

@mratsim
Copy link

mratsim commented Jan 24, 2021

My VS code workspace storage has reached a ridiculous 150GB

image

The culprit is vscode cpptools which caches an insane amount per repo
image

@dbaeumer
Copy link
Member Author

dbaeumer commented Feb 8, 2021

Thanks!

@royalpeasantry
Copy link

royalpeasantry commented Mar 20, 2021

How about storing workspaceStorage in the workspace folder instead of the user folder? This way, deleting (or unmounting) the workspace folder will automatically clear the space.
[I had .config/Code/User/workspaceStorage/fbf0af652eb1ee45193948d8b9186f2d/ms-vscode.cpptools taking 18.3GB. Was it still useful? No way to know.]

+1 to this suggestion - just have a .vscodeWorkspaceStorage folder in the workspace instead of storing it elsewhere.

In my case workspace storage was just caching information that caused my build to fail. It took me hours to realize that vscode was storing cache data somewhere other than in the workspace directory. 'git clean -fdx' really should have gotten me back to a working state.

@pearson
Copy link

pearson commented Jun 21, 2021

@royalpeasantry's suggestion of moving that storage to the actual workspace folder seems like a simple, sensible solution. People do not necessarily expect there to be project data stored elsewhere on the system, and they certainly shouldn't be made to search for where their primary install drive space is going.

My case wasn't quite as bad as @mratsim's, but it would have been there soon. I was creating a couple C++ projects a day to work through examples or to test different things, and each one ended up with an ~1GB file from the CPP-TOOLS extension. There was over 100GB of space taken up by these orphaned files before SpaceSniffer was run and that workspaceStorage directory was discovered. While larger SSDs are getting less expensive, that's still a lot of primary install drive space to lose.

While both my case and @mratsim's case are related to the CPP-TOOLS extension, this is a problem that really should be fixed in VSCode itself. Enough applications leave orphaned data around as it is, and it appears as if this could be fixed easily enough.

Changing the workspaceStorage directory location might be considered "a significant change to VSCode" -- I don't know -- but it would be very useful to have an option for changing where it is located. A simple settings toggle to start using the project's workspace directory for that storage, rather than %APPDATA%\Code\User\workspaceStorage, could do an interim job of fixing the issue.

@Jorgezz
Copy link

Jorgezz commented Jul 23, 2021

You can find it somewhat more readable in this gist.

just workspace path diferent of ~/.config/Code/User/workspaceStorage/*

@pdfowler
Copy link

pdfowler commented Mar 29, 2022

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:

  1. Extensions can set a default enabledFiletypes property in the extension registry
  2. When opening a workspace, any extensions with the enabledFiletypes property would be cross checked with the filetypes present in the project
  3. If there is an intersection, enable the extension, otherwise disable it by default.

Considerations

  1. 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.
  2. The behavior must be overridable at the user and workspace configuration levels, to both "always enable" and to override the enabledFiletypes
  3. 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.

@hinell
Copy link

hinell commented Aug 17, 2022

@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
Copy link

hinell commented Oct 26, 2022

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.

@ThirtySomething
Copy link

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 @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.

@starball5
Copy link

Loosely related Stack Overflow question: What are the effects of clearing the workspaceStorage folder for Visual Studio Code?

Related extension: mehyaa.workspace-storage-cleanup

@karl-lunarg
Copy link

karl-lunarg commented Mar 15, 2023

@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
Copy link

@starball5 and also @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
Copy link

Cache cleaning tools should be available as CLI since bloated caches can sometimes prevent starting the GUI.

@anibalsanchez
Copy link

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
Copy link

cspence001 commented May 22, 2024

FYI, under linux (and I suppose would work in OSX too) I'm cleaning up the workspace folders pointing non-existing locations with this inline script:

for i in ~/.config/Code/User/workspaceStorage/*; do if [ -f $i/workspace.json ]; then folder="$(python3 -c "import sys, json; print(json.load(open(sys.argv[1], 'r'))['folder'])" $i/workspace.json 2>/dev/null | sed 's#^file://##;s/+/ /g;s/%\(..\)/\\x\1/g;')"; if [ -n "$folder" ] && [ ! -d "$folder" ]; then echo "Removing workspace $(basename $i) for deleted folder $folder of size $(du -sh $i|cut -f1)"; rm -rfv "$i"; fi; fi; done

You can find it somewhat more readable in this gist.

For macOS users replace:
~/.config/Code/User/workspaceStorage/*
with:
~/Library/Application\ Support/Code/User/workspaceStorage/*

@hinell
Copy link

hinell commented 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality workbench-state UI state across restarts
Projects
None yet
Development

No branches or pull requests