You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[ExtensionDev] Expose API to get at file system locations #2741
Some extension relay on hard coded paths that are not exposed by vscode. See for example code-sittings-sync. Those extension are broken in the insiders version. I see t two possible ways:
Just expose all paths used by vscode to extensions. Otherwise they will hard code them. No more security, just more messy code.
Expose if the extension is used by the insider version. There might be a way, but I have not found it yet. I thought about getting the version and check if it ends with -insiders, but I have not found a way to get this information either.
Reacted by Sanders Lauture, Robert R., Mariusz Nowak, Jens Hausdorf, Gandalf Saxe, Axetroy, myfairsyer, Nathan Mador-House, Alexander, Daniel Wagner and 9 more
Interesting... the insider version should be considered as a separate product, with its own user settings and extensions folders. This enables a clean side-by-side install. Therefore, the code-sittings-sync extension is product specific, depending on whether it is installed in the insiders or the stable product it should sync the corresponding product settings.
An extension gets its path passed in the ExtensionContext of the activate call. From the extension path you can derive in which product the extension is installed. /.vscode-insiders/extensions/ or .vscode/extensions/.
Having said this a workaround, an extension should not have to do this path math and we exposing API to avoid this.
changed the title [-][ExtensionDev] How to find out if in insider mode.[/-][+][ExtensionDev] Expose API to get at file system locations[/+]on Feb 10, 2016
Alessandro Fragnani (@alefragnani) for the bookmark extension I believe you need the user config folder. is that right? Tobias Kahlert (@SrTobi) I am unsure if you only looking at sync'ing the user-level settings.json or also at others, like our keybindings.json and a potential future bookmarks.json etc
Johannes Rieken (@jrieken) potentially... Post #5570, it might be better to move snippets, settings.json and keybindings.json to the parent directory so it stays away from Chrome's config. Do you know if there's any reason it's in user data as opposed to sitting next to extensions?
Johannes Rieken (@jrieken) it should be fine to expose the User directory now, that will be the root config directory eventually after #3884. settings.json and keybindings.json will still be located there.
Expose if the extension is used by the insider version. There might be a way, but I have not found it yet. I thought about getting the version and check if it ends with -insiders, but I have not found a way to get this information either.
I'm using an extension that has an interactive help showing the keybindings that can be used, edamagit. Here's a small example:
Now the problem is, the user can change the keybindings in their keybindings.json. To make sure the correct keybindings are shown, the extension parses the keybindings.json.
Now the problem is, when using the extension remotely, there appears to be no way to get to this keybindings.json file. Delving into the vscode source, it appears that the correct URI to access keybindings.json is something like vscode-userdata:c:/Users/roblabla/AppData/Roaming/Code - Insiders/User/setting.json. The problem is, this URI depends on a ton of app and os-specific information that seems to be totally inaccessible from a remote extension.
The only way I've found to access it is by spawning the settings editor with workbench.action.openGlobalKeybindingsFile:
awaitcommands.executeCommand('workbench.action.openGlobalKeybindingsFile');letkeybindingsPath=null;for(letfofworkspace.textDocuments){if(f.uri.path.endsWith('keybindings.json')){KEYBINDINGS_FILE_URI_CACHE=f.uri;break;}}// Close the keybinding and default keybinding views.awaitcommands.executeCommand('workbench.action.closeActiveEditor');awaitcommands.executeCommand('workbench.action.closeActiveEditor');
which is a pretty terrible idea (it temporarily spawns a visible keybinding editor, which makes for a rather jarring experience...).
We closed this issue because we don't plan to address it in the foreseeable future. You can find more detailed information about our decision-making process here. If you disagree and feel that this issue is crucial: We are happy to listen and to reconsider.
Activity
egamma commentedon Feb 6, 2016
Interesting... the insider version should be considered as a separate product, with its own user settings and extensions folders. This enables a clean side-by-side install. Therefore, the code-sittings-sync extension is product specific, depending on whether it is installed in the insiders or the stable product it should sync the corresponding product settings.
An extension gets its path passed in the
ExtensionContextof theactivatecall. From the extension path you can derive in which product the extension is installed./.vscode-insiders/extensions/or.vscode/extensions/.Having said this a workaround, an extension should not have to do this path math and we exposing API to avoid this.
[-][ExtensionDev] How to find out if in insider mode.[/-][+][ExtensionDev] Expose API to get at file system locations[/+]jrieken commentedon May 12, 2016
To recap, the paths we should expose
/Users/jrieken/.vscode-oss-dev/extensions/Users/jrieken/Library/Application Support/code-oss-dev/UserI am unsure if we should also expose the individual files inside that folder like
settings.json,keybindings.jsoncos that list isn't finite.jrieken commentedon May 12, 2016
Alessandro Fragnani (@alefragnani) for the bookmark extension I believe you need the user config folder. is that right? Tobias Kahlert (@SrTobi) I am unsure if you only looking at sync'ing the user-level
settings.jsonor also at others, like ourkeybindings.jsonand a potential futurebookmarks.jsonetcalefragnani commentedon May 14, 2016
Johannes Rieken (@jrieken) exactly... thanks 👍
Tyriar commentedon May 15, 2016
FYI #5570 is moving the user data directory to be a sibling of the extensions dir.
jrieken commentedon May 17, 2016
Daniel Imms (@Tyriar) so should we expose the parent folder of those two directories?
Tyriar commentedon May 17, 2016
Johannes Rieken (@jrieken) potentially... Post #5570, it might be better to move snippets, settings.json and keybindings.json to the parent directory so it stays away from Chrome's config. Do you know if there's any reason it's in user data as opposed to sitting next to extensions?
jrieken commentedon May 17, 2016
no clue... João Moreno (@joaomoreno) or Benjamin Pasero (@bpasero) will know
13 remaining items
golf1052 commentedon Aug 5, 2016
Just wanted to check in on this. I assume this is also being pushed out past August like #3884
jrieken commentedon Aug 5, 2016
yeah - I am handcuffed as long as the underlying api/data isn't ready
Tyriar commentedon Aug 5, 2016
Johannes Rieken (@jrieken) it should be fine to expose the
Userdirectory now, that will be the root config directory eventually after #3884. settings.json and keybindings.json will still be located there.davidsk commentedon Oct 3, 2016
Any movement on this item? I'm after a way to reliably locate the snippets folder.
jrieken commentedon Oct 4, 2016
Sorry no - there is still no decision on how to re-structure the fs layout (which might then be a breaking change)
shanalikhan commentedon Jul 22, 2018
Johannes Rieken (@jrieken)
Any update on getting the paths for extensions and all those things for portable mode.
#49306
cantonios commentedon Dec 4, 2018
Most links related to obtaining the user-data-dir refer here, but the provided solution of using
storagePathis workspace-dependent.It seems
storagePathis the fs-equivalent of the mementoworkspaceState.Is there a similar option somewhere for the fs-equivalent of the memento
globalState?I could use the extension folder
extensionPath, but this would mean that data will be lost if you ever remove the plugin or update to a new version.usernamehw commentedon Jan 7, 2019
Is there anything terribly wrong with this way of getting
Userdir?octref commentedon Jul 3, 2019
Lakr233 commentedon Feb 2, 2020
I have been thinking it would be possible to get it from the shell
but an API is better for sure.
roblabla commentedon Sep 17, 2020
I have a bit of an odd need for this:
I'm using an extension that has an interactive help showing the keybindings that can be used, edamagit. Here's a small example:

Now the problem is, the user can change the keybindings in their keybindings.json. To make sure the correct keybindings are shown, the extension parses the keybindings.json.
Now the problem is, when using the extension remotely, there appears to be no way to get to this keybindings.json file. Delving into the vscode source, it appears that the correct URI to access keybindings.json is something like
vscode-userdata:c:/Users/roblabla/AppData/Roaming/Code - Insiders/User/setting.json. The problem is, this URI depends on a ton of app and os-specific information that seems to be totally inaccessible from a remote extension.The only way I've found to access it is by spawning the settings editor with
workbench.action.openGlobalKeybindingsFile:which is a pretty terrible idea (it temporarily spawns a visible keybinding editor, which makes for a rather jarring experience...).
Otherwise, the URI is available through the IEnvironmentService::keybindingsResource field, but this seems to be entirely inaccessible from extensions.
vscode-triage-bot commentedon Oct 12, 2021
We closed this issue because we don't plan to address it in the foreseeable future. You can find more detailed information about our decision-making process here. If you disagree and feel that this issue is crucial: We are happy to listen and to reconsider.
If you wonder what we are up to, please see our roadmap and issue reporting guidelines.
Thanks for your understanding and happy coding!