'Unable to write to Workspace Settings because .. is not a registered configuration

I am trying to update StatusBar color in VScode Setting.json using the Configuration and Workspace. But when the code tries to update I am getting following error:

Error: Unable to write to Workspace Settings because workbench.colorCustomizations.statusBar.background is not a registered configuration.

here is my code:

const conf = workspace.getConfiguration("workbench.colorCustomizations");
console.log('config-->'+JSON.stringify(conf));
await conf.update( "statusBar.background", "#00AA00");

On GetConfiguration I am getting the existing StatusBar color value but not able to Update it.



Solution 1:[1]

Maybe it is defaulting to workspace. You can specify global if you want to update it even though you haven't opened a workspace.

Without specifying the target, it will probably do this:

await conf.update("statusBar.background", "#00AA00", vscode.ConfigurationTarget.Workspace);

You may want to do this:

await conf.update("statusBar.background", "#00AA00", vscode.ConfigurationTarget.Global);

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Rigo da Silva