Reputation: 3086
I am setting up Visual Studio Code on Linux.
Since the machine is shared, my $HOME
folder is restricted in size, leaving me no space for extensions (which are stored in $HOME/.vscode/
), and that fails my attempts to install them.
I do have enough space on other development directory, but I couldn't find a way to tell Visual Studio Code to use another path, rather than $HOME
, for the global .vscode
folder.
Is there a way to do that without changing my $HOME
?
EDIT
While the suggestion in the comment solved the issue of extensions being installed in a different folder - there's a HUGE .cache
folder that's being filled by vscode in my $HOME
folder...
Is there a way to somehow change to path to this one as well?
Upvotes: 7
Views: 10490
Reputation: 1029
Some options in order of recommendation:
Your best option is probably to tell VS Code to use custom paths for extensions and user data. This would work since it would be the extensions and cache folders that take up disk space, and since the cache folders are located under the user data folder.
You provide the custom paths as command line arguments when invoking VS Code. Using /mnt/extdir/vsc-ext/
and /mnt/extdir/vsc-user-data/
as examples for desired external directories, you'd use:
$ code --extensions-dir /mnt/extdir/vsc-ext/ --user-data-dir /mnt/extdir/vsc-user-data/ .
You can add an alias to your shell startup script to facilitate this:
alias code='code --extensions-dir /mnt/extdir/vsc-ext/ --user-data-dir /mnt/extdir/vsc-user-data/'
Then you can continue to use just e.g. code .
as usual, but have VS Code use the external directories for extensions and cache.
From the CLI documentation:
--extensions-dir <dir>
Set the root path for extensions. Has no effect in Portable Mode.
--user-data-dir <dir>
Specifies the directory that user data is kept in, useful when running as root. Has no effect in Portable Mode.
Just a side note: I ran the following to confirm that the cache folders are actually under the user data directory:
$ mkdir vs-user-data && code --user-data-dir vs-user-data . && sleep 3 && ls vs-user-data | grep -i cache
CachedData
Code Cache
GPUCache
Using portable mode (documentation), all user data is stored in the installation directory, which is chosen by you.
This would probably work fine in your case, but a drawback would be a non-standard way for installation and making updating VS Code more cumbersome.
That would probably work as well, but would be an inferior option. The other solutions given above are officially supported and more robust.
Upvotes: 5