Revisit VS Code folder structure for app data, settings, extensions
Config is stored in ~/.config/Code[ - <quality>]/User. To match platform conventions (lowercase and hyphens for everything) as well as to keep consistency with the cli code[-<quality>] I propose we change the settings directory one of:
~/.config/code[-<quality>]/user~/.vscode[-<quality>](see https://github.com/Microsoft/vscode/issues/3883)~/.code[-<quality>](to prevent using 'vs' showing up in the OSS build as it is now)
If we moved this it would probably require some discovery/migration on first launch of a newer version.
The below is a living document.
Proposed folder structure
Notes:
- I don't think we should be encouraging the use of admin rights within vscode, instead a permissions elevation dialog would probably be better than allowing a specific place for root user data #5561
- I want to clean up the whole
codevsvscodething in this change; only official builds should carry the visual studio branding, that should carry over to the config directories consistently as well. - The CLI args
--user-data-dirand--extensions-dirwill need to be adjusted for this, something like--config-dirand--cache-dirwould probably be better.
Windows
Old
Settings: %APPDATA%\Code[ - Variant]\User\settings.json
Keybindings: %APPDATA%\Code[ - Variant]\User\keybindings.json
Snippets: %APPDATA%\Code[ - Variant]\User\snippets\
Workspace storage: %APPDATA%\Code[ - Variant]\User\workspaceStorage\
Chromium user data: %APPDATA%\Code[ - Variant]\
Extensions: %USERPROFILE%\.vscode[-variant]\extensions\
New
Settings: %APPDATA%\Microsoft\[Visual Studio ]Code[ - Variant]\settings.json
Keybindings: %APPDATA%\Microsoft\[Visual Studio ]Code[ - Variant]\keybindings.json
Snippets: %APPDATA%\Microsoft\[Visual Studio ]Code[ - Variant]\snippets\
Workspace storage: %LOCALAPPDATA%\Microsoft\[Visual Studio ]Code[ - Variant]\workspaceStorage\
Chromium user data: %LOCALAPPDATA%\Microsoft\[Visual Studio ]Code[ - Variant]\userdata\
Extensions: %LOCALAPPDATA%\Microsoft\[Visual Studio ]Code[ - Variant]\extensions\
Notes:
- Note that
%APPDATA%is roaming and%LOCALAPPDATA%is local, meaning extensions will not be carried across multiple machines until a solution is devised for #15442. An extension manifest, eg.%APPDATA%\Microsoft\[Visual Studio ]Code[ - Variant]\extensions.jsonwhich automatically installs extensions is my thinking of solving this problem.
Linux
Old
Settings: $HOME/.config/Code[ - Variant]/User/settings.json
Keybindings: $HOME/.config/Code[ - Variant]/User/keybindings.json
Snippets: $HOME/.config/Code[ - Variant]/User/snippets/
Workspace storage: $HOME/.config/Code[ - Variant]/User/workspaceStorage/
Chromium user data: $HOME/.config/Code[ - Variant]/
Extensions: $HOME/.vscode[-variant]/extensions/ (not moving)
New
Settings: $XDG_CONFIG_HOME/[vs]code[-variant]/settings.json
Keybindings: $XDG_CONFIG_HOME/[vs]code[-variant]/keybindings.json
Snippets: $XDG_CONFIG_HOME/[vs]code[-variant]/snippets/
Workspace storage: $XDG_CACHE_HOME/[vs]code[-variant]/workspaceStorage/
Chromium user data: $XDG_CACHE_HOME/[vs]code[-variant]/userdata/
Extensions: $XDG_CACHE_HOME/[vs]code[-variant]/extensions/
Notes:
- Thanks to @ollie27 and others for calling out the XDG Base Directory Specification, see that document for fallbacks to the environment variables.
$XDG_CACHE_HOMEwould be best for extensions provided there is an extensions manifest in$XDG_CONFIG_HOME#15442.- Maybe extensions should live in
$XDG_DATA_HOME?
Mac
Old
Settings: $HOME/Library/Application Support/Code[ - Variant]/User/settings.json
Keybindings: $HOME/Library/Application Support/Code[ - Variant]/User/keybindings.json
Snippets: $HOME/Library/Application Support/Code[ - Variant]/User/snippets/
Workspace storage: $HOME/Library/Application Support/Code[ - Variant]/User/workspaceStorage/
Chromium user data: $HOME/Library/Application Support/Code[ - Variant]/
Extensions: $HOME/.vscode[-variant]/extensions/ (not moving)
New
Settings: $HOME/Library/Application Support/[Visual Studio ]Code[ - Variant]/settings.json
Keybindings: $HOME/Library/Application Support/[Visual Studio ]Code[ - Variant]/keybindings.json
Snippets: $HOME/Library/Application Support/[Visual Studio ]Code[ - Variant]/snippets/
Workspace storage: $HOME/Library/Application Support/[Visual Studio ]Code[ - Variant]/workspaceStorage/
Chromium user data: $HOME/Library/Application Support/[Visual Studio ]Code[ - Variant]/userdata/
Extensions: $HOME/Library/Application Support/[Visual Studio ]Code[ - Variant]/extensions/
Notes:
- Is there a similar standard for dividing cache and config files on Mac? http://stackoverflow.com/a/5084892/1156119
I wonder if we should do this before GA. Besides the summary, I also do not like that we have 2 folders, one for application data and one for extensions. Ideally we have one folder for both.
It was a little confusing when I was writing my script that automates my config to discover there were 2 config folders. If this is going to be done I vote for ~/.code[-<quality>] so that it matches the executable name.
I am more worried about the migration than finding a name :)
I also don't get why there are two folders. Afaik .vscode only includes one subfolder, extensions. Why not simply put settings in .vscode aswell?
I also like .vscode more than .code, Visual Studio stuff is also in .vs and it is less ambiguous.
While fiddling with the config directories it might be worth tackling a portable version at the same time https://github.com/Microsoft/vscode/issues/329
Not for GA.
Btw the largest chunk of stuff in app date is created by Chrome itself and is used for local storage, index db, etc. It would be easy to migrate and move our settings out of that folder, I am worried about migrating the rest...
@bpasero what are your thoughts on getting this in for April? My experience with playing around with user data to date is that it seems fairly contained and can be moved without any issues.
The reason I want to do this soon is I'd like to have a set root user data dir as one is required to run under sudo (https://github.com/Microsoft/vscode/issues/5561). That would mean that instead of:
~/.vscode~/.config/Code~/.config/Code-Root
We could have
~/.vscode~/.vscode/user-data~/.vscode/user-data-root
For migration something like this should work in main.js:
if the regular config dir does not exists
if the old config dir does exist
copy the old config dir to the new location
@Tyriar happy to accept a PR on such a change and migration.
@Tyriar ah nice, did not see your PR until now!
Given my feedback, I am not suggesting to do this so late in the milestone.
@Tyriar any update on the current status? Thanks!
@sarbbottam still planned for May release.
Going to push back to July as I was too busy with Linux packaging improvements early this month.
eagerly waiting for this ... 🐱
Below is out of date, please see the top comment for the latest
So I'm going to move forward with this as:
<root_settings>/settings.json
<root_settings>/keybindings.json
<root_settings>/snippets/
<root_settings>/extensions/
<root_settings>/userdata/
<root_settings>/rootuserdata/
<root_settings>/workspaceStorage/
Where <root_settings> is the parent of the [extension directory]:
- Windows*:
%APPDATA%\Microsoft\Visual Studio Code[ - Variant] - Linux**:
$HOME/.vscode[- variant] - Mac**:
$HOME/.vscode[- variant]
* The folder name used is actually nameLong from the product.json (eg. Code - OSS, Visual Studio Code, Visual Studio Code - Insiders, etc.)
** The folder name used is actually dataFolderName from the product.json (eg. .vscode-oss, .vscode, .vscode-insiders, etc.)
Related issues:
- Windows roaming improvements will be partially done, moving extensions to %LOCALAPPDATA% but not creating an extension manifest of anything, meaning extensions will not carry across different machines on a corporate network.
- Automatic selection of the root user data directory (#5561) will be included with the
rootuserdatadirectory - I want to clean up the whole
codevsvscodething in this change.
Here is the complete picture:
Windows
Old
Settings: %APPDATA%\Code[ - Variant]\User\settings.json
Keybindings: %APPDATA%\Code[ - Variant]\User\keybindings.json
Snippets: %APPDATA%\Code[ - Variant]\User\snippets\
Workspace storage: %APPDATA%\Code[ - Variant]\User\workspaceStorage\
Chromium user data: %APPDATA%\Code[ - Variant]\
Chromium root user data: (manually specified)
Extensions: %USERPROFILE%\.vscode[-variant]\extensions\
New
Note that %APPDATA% is roaming and %LOCALAPPDATA% is local, meaning extensions _will not_ be carried across multiple machines until a solution is devised for #7035.
Settings: %APPDATA%\Microsoft\[Visual Studio ]Code[ - Variant]\settings.json
Keybindings: %APPDATA%\Microsoft\[Visual Studio ]Code[ - Variant]\keybindings.json
Snippets: %APPDATA%\Microsoft\[Visual Studio ]Code[ - Variant]\snippets\
Workspace storage: %LOCALAPPDATA%\Microsoft\[Visual Studio ]Code[ - Variant]\workspaceStorage\
Chromium user data: %LOCALAPPDATA%\Microsoft\[Visual Studio ]Code[ - Variant]\userdata\
Chromium root user data: %LOCALAPPDATA%\Microsoft\[Visual Studio ]Code[ - Variant]\rootuserdata\
Extensions: %LOCALAPPDATA%\Microsoft\[Visual Studio ]Code[ - Variant]\extensions\
Linux
Old
Settings: $HOME/.config/Code[ - Variant]/User/settings.json
Keybindings: $HOME/.config/Code[ - Variant]/User/keybindings.json
Snippets: $HOME/.config/Code[ - Variant]/User/snippets/
Workspace storage: $HOME/.config/Code[ - Variant]/User/workspaceStorage/
Chromium user data: $HOME/.config/Code[ - Variant]/
Chromium root user data: (manually specified)
Extensions: $HOME/.vscode[-variant]/extensions/ (not moving)
New
Thanks to @ollie27 and others for calling out the XDG Base Directory Specification, see that document for fallbacks to the environment variables.
Settings: $XDG_CONFIG_HOME/[vs]code[-variant]/settings.json
Keybindings: $XDG_CONFIG_HOME/[vs]code[-variant]/keybindings.json
Snippets: $XDG_CONFIG_HOME/[vs]code[-variant]/snippets/
Workspace storage: $XDG_CACHE_HOME/[vs]code[-variant]/workspaceStorage/
Chromium user data: $XDG_CACHE_HOME/[vs]code[-variant]/userdata/
Chromium root user data: $XDG_CACHE_HOME/[vs]code[-variant]/rootuserdata/
Extensions*: $XDG_CACHE_HOME/[vs]code[-variant]/extensions/
* $XDG_DATA_HOME may be a better candidate for extensions, my thinking is putting it in $XDG_CACHE_HOME and eventually having an extensions.json in $XDG_CONFIG_HOME which details a list of extensions to be installed.
Mac
Old
Settings: $HOME/Library/Application Support/Code[ - Variant]/User/settings.json
Keybindings: $HOME/Library/Application Support/Code[ - Variant]/User/keybindings.json
Snippets: $HOME/Library/Application Support/Code[ - Variant]/User/snippets/
Workspace storage: $HOME/Library/Application Support/Code[ - Variant]/User/workspaceStorage/
Chromium user data: $HOME/Library/Application Support/Code[ - Variant]/
Chromium root user data: (manually specified)
Extensions: $HOME/.vscode[-variant]/extensions/ (not moving)
New
Settings: $HOME/Library/Application Support/[Visual Studio ]Code[ - Variant]/settings.json
Keybindings: $HOME/Library/Application Support/[Visual Studio ]Code[ - Variant]/keybindings.json
Snippets: $HOME/Library/Application Support/[Visual Studio ]Code[ - Variant]/snippets/
Workspace storage: $HOME/Library/Application Support/[Visual Studio ]Code[ - Variant]/workspaceStorage/
Chromium user data: $HOME/Library/Application Support/[Visual Studio ]Code[ - Variant]/userdata/
Chromium root user data: $HOME/Library/Application Support/[Visual Studio ]Code[ - Variant]/rootuserdata/
Extensions: $HOME/Library/Application Support/[Visual Studio ]Code[ - Variant]/extensions/
@Tyriar This was probably a typo within the GitHub reply and you may have already noticed this, but within the "complete picture" the snippets and extensions paths have been swapped for all platforms:
Snippets: %USERPROFILE%.vscode[-variant]\extensions
Extensions: %LOCALAPPDATA%.vscode[-variant]\snippets\
Just making sure...
@QuietusPlus thanks, I posted a little early. I just fixed up a few issues including this one. I also changed the format of the Windows setting directory to match platform standards.
I'd appreciate any feedback on the above proposal. The main open questions I have currently are:
-
Where is the standard place for application config on OS X? Should we use
$HOME/Library/Application Support/Visual Studio Code[ - Variant]/instead of$HOME/.vscode[-variant]? (As per @joaomoreno's comment https://github.com/Microsoft/vscode/issues/7035#issuecomment-222618737, I'm using application support above) -
Should we take this opportunity to cull the 'vs' from
.vscode[-variant]in the open source builds? ie. change:"dataFolderName": ".vscode-oss", "win32MutexName": "vscodeoss", // This too?to
"dataFolderName": ".code-oss", "win32MutexName": "codeoss", -
Whether everything else sounds good.
/cc @joaomoreno @bpasero @rebornix
Workspace storage: %APPDATA%\Microsoft\Visual Studio Code[ - Variant]\workspaceStorage\
Chromium user data: %APPDATA%\Microsoft\Visual Studio Code[ - Variant]\userdata\
Chromium root user data: %APPDATA%\Microsoft\Visual Studio Code[ - Variant]\rootuserdata\
What is in these folders? Can they grow unboundedly or are they basically just "settings" type things? If they can grow unboundedly (e.g., a cache folder, a build output directory, plugins folder, etc.) then they should probably go in %LOCALAPPDATA%.
I'm curious why the names are different on Linux? In Linux, is there a convention to not use spaces in folder names? If so, then I support the difference.
Thanks @Zoltu, I changed user data folders to be %LOCALAPPDATA% as they are Chromium's data dirs and contain a bunch of files. My Cache directory inside the user data directory is 187mb for example. Workspace storage is just a few small json files. The only problem with this is that local storage will no longer roam, not sure all the implications of this but popups that the user told to not show again will show up again on a new machine.
In Linux for user-specific configurations it's common practice to keep them in a dir with a dot on the front which means they will be hidden by default. All lowercase with hyphens is also standard for files/folders on Linux.
Here is to hoping that the Chromium stuff behaves well when its folders randomly disappear between runs. :)
One thing I find weird is that you nest the Visual Studio Code folder under a Microsoft folder. The big Visual Studio simply installs to C:\Program Files\Microsoft Visual Studio, I think VS Code should do it the same way (don't nest, but prefix).
I really really like this whole clean-up, especially with moving to appdata on Windows and dropping the User folder (as this is already in the user's personal folder)
cc @Microsoft/vscode: please review @Tyriar's proposal
+100 for moving data from $HOME/.vscode*to $HOME/Library/Application Support/Visual Studio Code*.
Files and folders starting with a '.' are by default not visible in the OS X Finder and need special treatment when navigating into them whereas $HOME/Library/Application Support/ is just a normal folder (after making it visible once).
@felixfbecker I'm on my phone at the moment so finding a link is difficul but I believe that the Microsoft recommendation is to nest in a vendor folder (Microsoft in this case). I believe Visual Studio (full) is doing it wrong by not nesting. There is an article on MSDN somewhere that specifies best practice for this stuff.
@Tyriar not sure if roaming is Windows only, but Workspace storage should be in local app data and not room. We don't room the workspace so additional data associated with a workspace in workspace storage shouldn't room either.
@dbaeumer thanks, moved workspace storage to %LOCALAPPDATA%.
Another open question for @bpasero: what is %APPDATA%\Code - Insiders\storage.json and why isn't that using localStorage? It just looks like yet another place for PC-specific settings to be dumped. Is this where localStorage is moving?
@Tyriar There are two other processes that don't have access to local storage: the main and the shared process.
I also have to suggest to not call workspaceStorage but simply storage. There is a need to have global storage that can be accessed globally, not just scoped by workspaces. Global storage currently is a big mess, but we should build a foundation upon which to proceed.