microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.82k stars 29.5k forks source link

Revisit VS Code folder structure for app data, settings, extensions #3884

Open Tyriar opened 8 years ago

Tyriar commented 8 years ago

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:

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:

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:

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:

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:

bpasero commented 8 years ago

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.

Tyriar commented 8 years ago

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.

bpasero commented 8 years ago

I am more worried about the migration than finding a name :)

felixfbecker commented 8 years ago

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.

Tyriar commented 8 years ago

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

bpasero commented 8 years ago

Not for GA.

bpasero commented 8 years ago

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

Tyriar commented 8 years ago

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

We could have

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
bpasero commented 8 years ago

@Tyriar happy to accept a PR on such a change and migration.

bpasero commented 8 years ago

@Tyriar ah nice, did not see your PR until now!

bpasero commented 8 years ago

Given my feedback, I am not suggesting to do this so late in the milestone.

sarbbottam commented 8 years ago

@Tyriar any update on the current status? Thanks!

Tyriar commented 8 years ago

@sarbbottam still planned for May release.

Tyriar commented 8 years ago

Going to push back to July as I was too busy with Linux packaging improvements early this month.

sarbbottam commented 8 years ago

eagerly waiting for this ... 🐱

Tyriar commented 8 years ago

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]:

* 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:

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/
QuietusPlus commented 8 years ago

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

Tyriar commented 8 years ago

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

Tyriar commented 8 years ago

I'd appreciate any feedback on the above proposal. The main open questions I have currently are:

/cc @joaomoreno @bpasero @rebornix

MicahZoltu commented 8 years ago
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.

Tyriar commented 8 years ago

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.

MicahZoltu commented 8 years ago

Here is to hoping that the Chromium stuff behaves well when its folders randomly disappear between runs. :)

felixfbecker commented 8 years ago

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)

joaomoreno commented 8 years ago

cc @Microsoft/vscode: please review @Tyriar's proposal

weinand commented 8 years ago

+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).

MicahZoltu commented 8 years ago

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

dbaeumer commented 8 years ago

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

Tyriar commented 8 years ago

@dbaeumer thanks, moved workspace storage to %LOCALAPPDATA%.

Tyriar commented 8 years ago

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?

joaomoreno commented 8 years ago

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

Tyriar commented 8 years ago

@joaomoreno but there is also a storage.json which will likely be going into the same folder as workspaceStorage.json. Cleaning up that side of things after this would be good.

Tyriar commented 8 years ago

Pushing out to August as the start of this month was largely spent gathering requirements. Please comment if you have any concerns with the direction before then.

Tyriar commented 8 years ago

This is getting pushed out beyond August due to relative low priority compared to my other issues.

ollie27 commented 8 years ago

On Linux I think we should continue to follow the XDG Base Directory Specification. So use $XDG_CONFIG_HOME (~/.config/), $XDG_CACHE_HOME (~/.cache/) and $XDG_DATA_HOME (~/.local/share/). I'm not completely sure how best to separate the directories but something like the following might work:

Settings:                $XDG_CONFIG_HOME/vscode[-variant]/settings.json
Keybindings:             $XDG_CONFIG_HOME/vscode[-variant]/keybindings.json
Snippets:                $XDG_CONFIG_HOME/vscode[-variant]/snippets/
Workspace storage:       $XDG_DATA_HOME/vscode[-variant]/workspaceStorage/
Chromium user data:      $XDG_CACHE_HOME/vscode[-variant]/userdata/
Chromium root user data: $XDG_CACHE_HOME/vscode[-variant]/rootuserdata/
Extensions:              $XDG_DATA_HOME/vscode[-variant]/extensions/
ghost commented 8 years ago

100% agree with ollie27. Dumping stuff in the home directory is bad. Please use XDG directories.

felixfbecker commented 8 years ago

Well for Windows settings might get saved in the registry then instead 😄

kaleb commented 8 years ago

Why is it being proposed to move away from the XDG Base Directory standard on Linux environments? I agree with @ollie27 .

Tyriar commented 8 years ago

@ollie27 $XDG_CONFIG_HOME is not actually set on Ubuntu 16.04, where would you expect to be used in this case?

ollie27 commented 8 years ago

@Tyriar like is currently done (https://github.com/Microsoft/vscode/blob/746f66a6e7c164a6b920b439c23865f16b9a9b03/src/paths.js#L14) it would fall back to ~/.config. The defaults are described on https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html.

octref commented 8 years ago

I think we should use electron's app.getPath('appData')

which resolves to:

Tyriar commented 8 years ago

@octref vscode defines that, the result of the discussion will determine what to set appData as. https://github.com/Microsoft/vscode/blob/2f76c44632b0d47ba97f66fbc158c763628e30b3/src/paths.js#L10

romange commented 8 years ago

Guys, I would like to vote to see this issue resolved . Specifically, having User/workspaceStorage being pulled from User.. This will enable users to share the same settings among multiple workstations using dropbox or similar cloud clients. Today this is hard to do because workspaceStorage takes hundreds of megabytes and it's also specific per workstation.

felixfbecker commented 8 years ago

@romange there is an extension that syncs your settings and extensions.

Tyriar commented 8 years ago

@romange After the eventual change, settings.json will still be a sibling of workspaceStorage and the user data directory, etc. So that wouldn't help either. I suggest trying out the sync extension or writing some scripts to manage it yourself.

romange commented 8 years ago

Thanks for the tip - using sync extension is great, thanks!

jcrben commented 8 years ago

Would rather not use an extension - I have a system for syncing my stuff (especially configs inside XDG_CONFIG_HOME) and would prefer that it fits into that system. Also, glad that the conversation moved away from using the folder .code - please, keep it .vscode or something equally descriptive. We don't have namespaces here so it's up to application developers to be responsible.

I don't see why it wouldn't just use $XDG_CONFIG_HOME if set and than fall back to the $HOME, the way that Git and various other applications handle the situation.

Tyriar commented 8 years ago

I moved the proposal to the original issue comment and updated:

jcrben commented 8 years ago

To clarify, I would be happiest if my macOS also placed the configs into XDG_CONFIG_HOME if I set the variable.

If not, can there be custom environment variables so that I use to make my configs the same location on Linux and macOS?

XDG_CONFIG_HOME (and other xdg directory variables) is a neat way to make your apps behave more nicely cross-platform.

Tyriar commented 8 years ago

@jcrben you can already set this using the CLI:

  --user-data-dir <dir>       Specifies the directory that user data is kept
                              in, useful when running as root.
  --extensions-dir <dir>      Set the root path for extensions.

So you could do:

code --user-data-dir $XDG_CONFIG_HOME --extensions-dir $XDG_CONFIG_HOME

This will currently lump all files (even non-config files) into the directory though which may not be desirable. I'll call out in the original comment that the CLI will also need to be amended, we would definitely want to align with whatever the platform recommends by default though.

jcrben commented 7 years ago

Note that Git respects XDG_CONFIG_HOME when set on macOS just fine - there is no disadvantage to respecting the environment variable if set.

I see that there's a CLI way to customize the location, but how about an an environment variable? That seems more typical and less clunky.