vscode icon indicating copy to clipboard operation
vscode copied to clipboard

[ExtensionDev] Expose API to get at file system locations

Open SrTobi opened this issue 10 years ago • 28 comments

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:

  1. Just expose all paths used by vscode to extensions. Otherwise they will hard code them. No more security, just more messy code.
  2. 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.

SrTobi avatar Feb 05 '16 17:02 SrTobi

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.

egamma avatar Feb 06 '16 17:02 egamma

To recap, the paths we should expose

  • [ ] extensions home folder, like /Users/jrieken/.vscode-oss-dev/extensions
  • [ ] user config folder, like /Users/jrieken/Library/Application Support/code-oss-dev/User

I am unsure if we should also expose the individual files inside that folder like settings.json, keybindings.json cos that list isn't finite.

jrieken avatar May 12 '16 09:05 jrieken

@alefragnani for the bookmark extension I believe you need the user config folder. is that right? @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

jrieken avatar May 12 '16 09:05 jrieken

@jrieken exactly... thanks 👍

alefragnani avatar May 14 '16 23:05 alefragnani

FYI https://github.com/Microsoft/vscode/pull/5570 is moving the user data directory to be a sibling of the extensions dir.

Tyriar avatar May 15 '16 00:05 Tyriar

@Tyriar so should we expose the parent folder of those two directories?

jrieken avatar May 17 '16 13:05 jrieken

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

Tyriar avatar May 17 '16 15:05 Tyriar

no clue... @joaomoreno or @bpasero will know

jrieken avatar May 17 '16 15:05 jrieken

Historic reasons, we only had extensions folder a lot later.

bpasero avatar May 17 '16 16:05 bpasero

Is it worth simplifying the structure further as part of #5570?

.vscode/settings.json
.vscode/keybindings.json
.vscode/snippets/
.vscode/extensions/
.vscode/userdata/
.vscode/rootuserdata/

Tyriar avatar May 17 '16 17:05 Tyriar

Moving to June considering those potential upcoming changes

jrieken avatar May 23 '16 07:05 jrieken

I like that very much.

joaomoreno avatar May 24 '16 07:05 joaomoreno

@joaomoreno @Tyriar where are we with this and what's the plan?

jrieken avatar May 31 '16 15:05 jrieken

The pull is quite stale and probably needs to be redone, there is also the complication of Windows directory changing as well #7035. Just a matter of prioritizing it against the other stuff in my backlog (mainly terminal bugs and linux packaging improvements).

Tyriar avatar May 31 '16 15:05 Tyriar

@jrieken I'd like #7035 to be figured out before moving on this again. We don't really want to be migrating settings around multiple times if we can prevent it. It sounds like #7035 would need an extensions manifest to correctly support roaming on Windows.

Considering that settings.json and keybindings.json would probably best be situated at the root directory, not in Chromium's user data, how about we make an API to get at the User directory for now, which will eventually become the root?

<root_settings>/settings.json
<root_settings>/keybindings.json
<root_settings>/snippets/
<root_settings>/extensions/
<root_settings>/userdata/
<root_settings>/rootuserdata/

Tyriar avatar Jun 03 '16 01:06 Tyriar

Sorry, again we didn't get to this... Tho we added a storagePath property for those extension that want to store state that doesn't fit into mementos but needs files/folders

jrieken avatar Jun 25 '16 09:06 jrieken

Just wanted to check in on this. I assume this is also being pushed out past August like https://github.com/Microsoft/vscode/issues/3884

golf1052 avatar Aug 05 '16 03:08 golf1052

yeah - I am handcuffed as long as the underlying api/data isn't ready

jrieken avatar Aug 05 '16 07:08 jrieken

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

Tyriar avatar Aug 05 '16 07:08 Tyriar

Any movement on this item? I'm after a way to reliably locate the snippets folder.

davidsk avatar Oct 03 '16 12:10 davidsk