Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Have a setting for the extensions folder location #17691

Closed
benguenter opened this issue Dec 21, 2016 · 42 comments
Closed

Have a setting for the extensions folder location #17691

benguenter opened this issue Dec 21, 2016 · 42 comments
Assignees
Labels
extensions Issues concerning extensions

Comments

@benguenter
Copy link

  • VSCode Version: 1.8.1
  • OS Version: Win 10

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

@alefragnani
Copy link

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

@egamma egamma added the info-needed Issue requires more information from poster label Dec 22, 2016
@egamma
Copy link
Member

egamma commented Dec 22, 2016

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

@benguenter
Copy link
Author

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 egamma added feature-request Request for new features or functionality workbench and removed info-needed Issue requires more information from poster labels Dec 25, 2016
@totkeks
Copy link

totkeks commented Jan 12, 2017

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

@davestephens
Copy link

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

@tobciu
Copy link

tobciu commented Mar 27, 2017

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

@Igetin
Copy link

Igetin commented May 9, 2017

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.

@bpasero bpasero changed the title Move Extensions Folder Have a setting for the extensions folder location Nov 16, 2017
@bpasero bpasero added extensions Issues concerning extensions and removed workbench labels Nov 16, 2017
@kevinding0218
Copy link

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!

@antonio6643
Copy link

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.

@message2prateek
Copy link

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.

@beccabusan
Copy link

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

@tobciu
Copy link

tobciu commented Apr 3, 2018

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

@maxifocus
Copy link

maxifocus commented May 3, 2018

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.

@uxtx
Copy link

uxtx commented May 17, 2018

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"

@gayshub
Copy link

gayshub commented Sep 26, 2018

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.

@ghost
Copy link

ghost commented Nov 2, 2018

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.

@pauloofmeta
Copy link

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.

@eazrael
Copy link

eazrael commented Mar 26, 2019

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\""

@Webreaper
Copy link

Webreaper commented May 14, 2019

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.

@zc1789284658
Copy link

zc1789284658 commented Jul 7, 2019

hello,i 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,you should make sure that the source dir is empty
  2. after you make link between the two dirs,you could copy the files to the target direction.
  3. the powershell can not recognize mklink,if u are in windows , u should run mklink in cmd
  4. for safe,you 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

@davidone
Copy link

davidone commented Jul 26, 2019

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.

@wschin
Copy link

wschin commented Aug 2, 2019

hello,i 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,you should make sure that the source dir is empty
after you make link between the two dirs,you could copy the files to the target direction.
the powershell can not recognize mklink,if u are in windows , u should run mklink in cmd
for safe,you 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.

@rhewy
Copy link

rhewy commented Aug 20, 2019

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.

@caparkaya
Copy link

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.

@caparkaya
Copy link

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.

@erlantorres
Copy link

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

@rhewy
Copy link

rhewy commented Aug 24, 2019

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?

@erlantorres
Copy link

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.

@chrisschuyler
Copy link

chrisschuyler commented Nov 27, 2019

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!

@eazrael
Copy link

eazrael commented Nov 27, 2019

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

@AlexAegis
Copy link

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

@sandy081
Copy link
Member

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.

@sandy081 sandy081 removed the feature-request Request for new features or functionality label Nov 11, 2020
@sandy081 sandy081 removed this from the On Deck milestone Nov 11, 2020
@rhewy
Copy link

rhewy commented Nov 11, 2020

Does the env VSCODE_EXTENSIONS work now in version 1.51.0?

@sandy081
Copy link
Member

Yes

@rhewy
Copy link

rhewy commented Nov 11, 2020

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?

@Erithax
Copy link

Erithax commented Nov 21, 2020

This issue is closed?! Nowhere can I find how to actually set this env variable. Can someone at least put some instructions here?

@rhewy
Copy link

rhewy commented Nov 21, 2020

Are you on windows?

@Erithax
Copy link

Erithax commented Nov 27, 2020

Are you on windows?

Yes.

@rhewy
Copy link

rhewy commented Nov 27, 2020

Open up System Properties in the control panel:
env_var_01

Or start to type 'env' in the search of the task bar. This option will present to you two choices:

  • Edit the system environment variables
  • Edit environment variables for your account

You will end up at the same dialog but the top is you and the bottom is the system. I use system, others will not but I install VScode on a VDI so I need it set for everybody who might login.

Then click new:
env_var_03

Then fill in the info for the new var:
env_var_02

I hope this helps and good luck.

@Erithax
Copy link

Erithax commented Nov 28, 2020

Thanks! That was easy. Problem is though, that I wanted to move the .vscode folder, which it's still created everytime I launch, containing argv.json. I guess I should go complain in this issue.
* I saw that issue mentioned, but apparently that's not in this repo. So I created my own.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
extensions Issues concerning extensions
Projects
None yet
Development

No branches or pull requests