Vscode: Have a setting for the extensions folder location

Created on 21 Dec 2016  路  37Comments  路  Source: microsoft/vscode

  • VSCode Version: 1.8.1
  • OS Version: Win 10

Is there any way to permanently change where Extensions are installed and run for vscode?

extensions

Most helpful comment

@egamma There is another reason, also in the workplace environment. The current extension folder resides inside .vscode folder in the %USERPROFILE% folder on windows which is part of the profile and thus synced to the domain server.
It would probably be better located inside the appdata\local folder.

All 37 comments

Hi @benguenter ,

Unfortunately there is no User Config for that.

But as a workaround you could use --extensions-dir command line parameter while opening Code, updating your Shortcuts/Icons or creating a batch file to use, instead of code.exe while using terminal.

Hope this helps

@benguenter what is your use case for changing the default location of extensions?

Excellent, thankyou @alefragnani that helps.

@egamma The reason I am looking for this is because at my workplace there is an applocker policy restricting programs/scripts from running in the appdata directory for security reasons. I was able to get around it by creating a symlink to a separate folder that was allowed but the config is a better solution.

@egamma There is another reason, also in the workplace environment. The current extension folder resides inside .vscode folder in the %USERPROFILE% folder on windows which is part of the profile and thus synced to the domain server.
It would probably be better located inside the appdata\local folder.

@egamma I have a similar issue at my place of work, but it's due to a quota being applied to the user profile folder which is synced back to the domain server. Agree with @totkeks regarding saving it to a non-synced location.

+1
i need this for my workplace, because i have only 50MB of profile space, so i can't install any extension ...

I don't have a quota for the user profile at work, but having all the extensions in the user profile makes logging in tediously slow.

I have to run the command everytime when I open VS Code since my USERPROFILE contains special character like "%" or "&" that Omnisharp won't be able to recognize the default path everytime it launches.
Looking for a solution to change the installed extension folder forever!

This feature would really help. I use the zip-version on a non-admin account on my school laptop, so I can't install most extensions unfortunately.

I switched from Atom to VScode just because I can change the location of the extension data using the "--extensionHomePath" in the shortcut for VSCode. However, even this is unsatisfactory because everytime VSCode updates, I have to re-edit the shortcut. Please provide this feature.

@message2prateek - It sounds like that is something I would like to do. However, I do not quite understand how you do it, where can you change the shortcut (is it the .exe file or du you only start VS Code via the terminal? Could you please explain further?

hello @beccabusan you can create a shortcut of the .exe and add the parameter, see screenshot:
vscode-shortcut

Having a setting for defining the extensions path would be great, so I don't have to change the shortcut everytime I install an update.

This would be super helpful - for the time being, I've had to alias code to sets my extension:

alias ecode="code --extensions-dir ~/somedir/.vscode/extensions"

That better to add the function to setting of vscode, my username directory is "what'sup", it's install in C:\Users\what'sup\.vscode\extensions\ when I have installed vscode default, but some plugin program require the ditectory of components with that directory, the syntax got wrong with require ' C:\Users\what'sup\.vscode\extensions\', cause the single quotes of what'up got intercept.

Add me to the list of people needing this setting. It seems that the registry entries with the command line parameter are overwritten by updates. Pretty annoying.

Add me to! my profile space is limited at work.

https://code.visualstudio.com/docs/editor/portable

This mode also provides a way to set the installation folder location for VS Code extensions, useful for corporate environments that prevent extensions from being installed in the Windows AppData folder.

Hi, because of a security rule in my company, i needed to change the installation path of extensions, today i am doing this through the parameter --extensions-dir, but this parameter i can only use as an argument when starting vscode, i would suggest the creation of a configuration to inform the path of the extensions, so it would be much better to open the vscode through of the console code.

Still pretty annoying to change the registry after each update. Here's my registry file:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Applications\Code.exe\shell\open\command]
@="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\" --extensionHomePath \"%LOCALAPPDATA%\\.vscode\\extensions\" -n \"%1\""

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\VSCodeSourceFile\shell\open\command]
@="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\" --extensionHomePath \"%LOCALAPPDATA%\\.vscode\\extensions\" -n  \"%1\""

[HKEY_USERS\S-1-5-21-2034166366-3704758622-3460286468-1000\Software\Classes\vscode\shell\open\command]
@="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\" --extensionHomePath \"%LOCALAPPDATA%\\.vscode\\extensions\" --open-url -- \"%1\""

[HKEY_USERS\S-1-5-21-2034166366-3704758622-3460286468-1000_Classes\vscode\shell\open\command]
@="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\" --extensionHomePath \"%LOCALAPPDATA%\\.vscode\\extensions\" --open-url -- \"%1\""

Also hitting this - as others have mentioned, corporate roaming profiles do not work well with javascript extensions that can amount to Gigabytes of storage, and tens or hundreds of thousands of tiny files.

It's also worth pointing out that modifying shortcuts to add the --extensions-dir setting certainly works, but only if you're directly launching VSCode. If you're launching it via a file association by double-clicking on a source file, it'll revert to the default location.

Portable mode is a possibility, but the easiest thing would be if VSCode could have an env var added (VSCODE_EXTENSIONS_HOME or something) which would override the default storage location for extensions. That way, it would become trivial to roll out a global change to a large population of developers to put the extensions storage into a more practical location.

hello锛宨 think u can use command link to resolve this problem.

if you are in unix ,the command ln -s is useful,

# in unix-like system
/usr > ln -s  /xxx/.vscode/extensions /usr/local/test/VSCodeExtensions/extensions

if you are in windows, the command mklink /J is useful

# in windows , my command is
C:\WINDOWS\system32>mklink /J C:\Users\87716\.vscode\extensions D:\Develop\VSCodeExtensions\extensions

tips

  1. before you mklink or ln -s锛寉ou should make sure that the source dir is empty
  2. after you make link between the two dirs锛寉ou could copy the files to the target direction.
  3. the powershell can not recognize mklink锛宨f u are in windows , u should run mklink in cmd
  4. for safe锛寉ou should run cmd with administrator

summary in windows

  1. move the extentions from C:\Users\87716.vscode\extensions to TargetDir
mv  C:\Users\87716\.vscode\extensions\*      D:\Develop\VSCodeExtensions\extensions
  1. make link with C:\Users\87716.vscode\extensions and TargetDir
mklink  /J   C:\Users\87716\.vscode\extensions   D:\Develop\VSCodeExtensions\extensions

It also seems that this option is not supported within WSL:

$ code --extensionHomePath "C:\vscode_extensions" .
Ignoring option extensions-dir: not supported for code.

Context: I am using WSL + Docker + VSCode (so using VSCode Remote) but I have an apostrophe on my last name (Foo'Bar) and I cannot change the %USERPROFILE% directory because I'm using a corporate laptop so I created a C:\vscode_extensions directory to override that.

OS: Windows 10 17763.615 x64_86.

hello锛宨 think u can use command link to resolve this problem.
if you are in unix ,the command ln -s is useful,

in unix-like system

/usr > ln -s /xxx/.vscode/extensions /usr/local/test/VSCodeExtensions/extensions
if you are in windows, the command mklink /J is useful

in windows , my command is

C:\WINDOWS\system32>mklink /J C:\Users\87716.vscode\extensions D:\Develop\VSCodeExtensions\extensions
tips

before you mklink or ln -s锛寉ou should make sure that the source dir is empty
after you make link between the two dirs锛寉ou could copy the files to the target direction.
the powershell can not recognize mklink锛宨f u are in windows , u should run mklink in cmd
for safe锛寉ou should run cmd with administrator

summary in windows

move the extentions from C:\Users\87716.vscode\extensions to TargetDir

mv C:\Users\87716.vscode\extensions* D:\Develop\VSCodeExtensions\extensions

make link with C:\Users\87716.vscode\extensions and TargetDir

mklink /J C:\Users\87716.vscode\extensions D:\Develop\VSCodeExtensions\extensions

This works for me. I don't want to use tool much memory in my home directory, so I

  1. Create a directory '.vscode-serverin/anotherdisk`
  2. ln -s /anotherdisk/.vscode-server /home/me/.vscode-server.
  3. Create a directory .vscode in /anotherdisk
  4. ln -s /anotherdisk/.vscode /home/me/.vscode.

This way vscode would install big files to another disk.

Use case "Windows VDI deployment for Python Development". I work at an educational institute (BCIT). We support remote apps for online and campus courses. We want a consistently configured Python IDE (we are testing VS Code). We want the IDE to launch in a reasonable timeframe. Currently some of us are trying to copy the extensions to the user's profile just before the VSCode launches. I will try the --extensionHomePath, however, making sure we cover every way the IDE can be opened could be tricky. Having a file such as the idea.properties file that JetBrains uses would help.

We use VS Code on a Terminal Server in a multi-user environment. We want all users to use a common set of extensions, installed and updated once (for operational and disk space reasons). We do not prefer portable mode because we want settings customizations kept separately for each user. So I also vote for a permanant setting for extensions root path, which does not require each call of code.cmd to be customized.

Use case "Windows VDI deployment for Python Development". I work at an educational institute (BCIT). We support remote apps for online and campus courses. We want a consistently configured Python IDE (we are testing VS Code). We want the IDE to launch in a reasonable timeframe. Currently some of us are trying to copy the extensions to the user's profile just before the VSCode launches. I will try the --extensionHomePath, however, making sure we cover every way the IDE can be opened could be tricky. Having a file such as the idea.properties file that JetBrains uses would help.

I would say just the same, this is achieved with idea.properties file in IntelliJ.

  • VSCode Version: 1.8.1
  • OS Version: Win 10

Is there any way to permanently change where Extensions are installed and run for vscode?

Hi,

You just need to add a tag --extensions-dir="" in file code.cmd located in vscode's instalation path: "..\Microsoft VS Code\bin". Like this:

this is original file configuration:

@echo off
setlocal
set VSCODE_DEV=
set ELECTRON_RUN_AS_NODE=1
"%~dp0..\Code.exe" "%~dp0..\resources\app\out\cli.js" %*
endlocal

After adding the tag --extensions-dir:

@echo off
setlocal
set VSCODE_DEV=
set ELECTRON_RUN_AS_NODE=1
"%~dp0..\Code.exe" "%~dp0..\resources\app\out\cli.js" --extensions-dir="D:\Programs.vscode\extensions" %*
endlocal

After you do it, will be considered the extensions in you new directory and all new extensions will be instaled too. Also, will be possible to start vscode normally.

Hi,

The above tweak of the bin\code.cmd files does not work as described on VSC 1.37.1 on Win10.

It seems that on Win10, code.exe is ran directly and the bin\code.cmd file is bypassed

If I run bin\code.cmd manually with -extensionHomePath (not --extensions-dir=) then it seems to pick up the redirect, however, this would be the same modifying the Start Menu shortcut.

Currently, what would force bin\code.cmd to be called?

Hi,

The above tweak of the bin\code.cmd files does not work as described on VSC 1.37.1 on Win10.

It seems that on Win10, code.exe is ran directly and the bin\code.cmd file is bypassed

If I run bin\code.cmd manually with -extensionHomePath (not --extensions-dir=) then it seems to pick up the redirect, however, this would be the same modifying the Start Menu shortcut.

Currently, what would force bin\code.cmd to be called?

Yo,

You are right, need to set up the shortcut too. My first explanation works only in command line, this calls bin\code.cmd.
However, both tags works. In my case I used --extensions-dir=.

Thanks.

UPDATE: Upon investigation, you have VSCODE_EXTENSIONS as an env variable defined, and this does work to override the directory. Should this issue be closed and maybe need a PR for the docs?

This has been floating around for about 3 years. Regarding use-cases, my personal issue is around IT security, where they are trying to limit the execution to known and policed folders (the user folder is a big red flag for them).

Are there any functional reasons we can't implement this as a setting and/or an environment variable (e.g. in prep for submitting a PR around this)?

Thanks in advance!

Hero of the day :-) Not the people who implemented this, but you for this great finding :-)

@chrisschuyler Thanks! It works. For my usecase it's not about disk space but keeping a tidy $HOME folder, so using a symlink would do nothing in that regard.

Closing this in favour of VSCODE_EXTENSIONS env variable. If there is still a need for the setting, please reopen it by mentioning the use case.

Does the env VSCODE_EXTENSIONS work now in version 1.51.0?

Yes

Is there a list of VSCODE_* variables in the documentation somewhere? I have been looking but no luck so far.

Specifically for:
--disable-gpu
Can I set the above via and ENV VAR or a file in the SW-tree?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

villiv picture villiv  路  3Comments

trstringer picture trstringer  路  3Comments

curtw picture curtw  路  3Comments

VitorLuizC picture VitorLuizC  路  3Comments

shanalikhan picture shanalikhan  路  3Comments