8

I've got some extensions installed that are only enabled in a specific workspace.

With settings, normally workspace specific stuff is saved in .vscode/settings.json within the workspace folder. However, this doesn't seem to be the case for extensions.

I know extensions themselves are installed in .vscode/extensions within the user profile folder, but I can't find anything that dictates whether or not they're enabled or disabled. This is true for locally, remotely, and in a given workspace.

Checking through settings sync seems to show an extensions.json that lists all installed extensions with their enabled/disabled state, but I can't find this file locally anywhere in either my workspace, my remote, or locally.

Where is this configuration file?

Jademalo
  • 323
  • 1
  • 8

2 Answers2

7

From a quick test it appears that extension states are stored in state.vscdb sqlite databases under extensionsIdentifiers/disabled key

Global:

<vsc user profile folder>/user-data/User/globalStorage/state.vscdb

Workspace-specific:

<vsc user profile folder>/user-data/User/workspaceStorage/<workspace ID>/state.vscdb

For context, the global settings.json file location is

<vsc user profile folder>/user-data/User/settings.json

and really does not seem to store extensions list nor state; just their preferences.

myf
  • 9,874
  • 2
  • 37
  • 49
1

A previous SO answer by @gino-mempin described how to query the SQLite tables in the state.vscdb files that contain the extension states using the SQLite browser. To query the vscdb programmatically using PowerShell, please see another SO answer here about querying for cookies.

Recall that the global settings.json file location by operating system is

  • Windows %APPDATA%\Code\User\settings.json or $env:APPDATA\Code\User\settings.json
  • macOS $HOME/Library/Application\ Support/Code/User/settings.json
  • Linux $HOME/.config/Code/User/settings.json

I use an asterisk * after Code to account for possible the Code - Insiders construction of the Insiders build, if you're on the Insiders channel. For global settings, relative to settings.json, state.vscdb is located in ./User/globalStorage/state.vscdb.

Resolve-Path "$env:APPDATA\Code*\User\globalStorage\state.vscdb"  # global settings store for extensions

For workspace specific settings, again relative to the settings.json, state.vscdb per workspace is stored in ./User/workspaceStorage/<ExtensionContext.storageUri>/state.vscdb

Again, for example, PowerShell in Windows:

Resolve-Path "$env:APPDATA\Code*\User\workspaceStorage\*\state.vscdb"  # workspace settings store for extensions

The ExtensionContext.storageUri refers to the uri of a workspace specific directory in which the extension can store private state. This can be found using the Developer Tools (Help > Toggle Developer Tools)

Toggle Developer Tools in the Help menu

Then, in the console, type

let config = await vscode.context.resolveConfiguration();
config.workspace;

Here is a screen recording of this process:

Getting the workspace ID from VS Code Developer Tools

See the VS Code API docs for more information on the ExtensionContext.storageUri within the context of extension development.

Mavaddat Javid
  • 491
  • 4
  • 19