Description
There are many of us who find it bad practice that VSCode creates a ~/.vscode/
folder instead of following the common XDG base directory structure, respected by a wide variety of programs. This issue has come up regularly, without a good permanent solution:
- Revisit VS Code folder structure for app data, settings, extensions #3884
- Not possible to define location of argv.json #84808
- Unified "--portable-dir <dir>" command line flag #100988
- Have a setting for the extensions folder location #17691
- Cache files not stored under appropriate XDG directory #126182
I would like to propose the following new behaviour:
- If
~/.config/vscode/argv.json
1 is present at launch in non-portable mode, then VSCode uses this as the path forargv.json
. argv.json
supports setting the following arguments, which the user can set to XDG-compatible paths if they like:
user-data-dir
extensions-dir
As far as I can tell, this would be sufficient to avoid creating a ~/.vscode/
folder. It also reuses the existing structure of VSCode to do this without introducing significant hacks, edge cases, or race conditions.
Part 1 seems reasonably feasible to me, given that argv.json
is hardcoded in delightfully few places at the moment: https://github.com/microsoft/vscode/search?q=%22argv.json%22&type=code
Part 2 would essentially involve adding those arguments to SUPPORTED_ELECTRON_SWITCHES
.
I'd be happy to submit a PR if this kind of approach is amenable to the maintainers.
Footnotes
-
If a non-branded or non-Insiders build is launched, this would generalize to
~/.config/[prefix]code[suffix]/argv.json
, per https://github.com/microsoft/vscode/issues/3884 . This is deterministic for any given installed build. ↩