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

WokspaceConfiguration.update() writes machine setting to user settings.json #102543

Closed
joelspadin-garmin opened this issue Jul 14, 2020 · 2 comments
Assignees
Labels
*duplicate Issue identified as a duplicate of another issue(s)

Comments

@joelspadin-garmin
Copy link

  • VSCode Version: 1.47.1
  • OS Version: Windows 10.0.17763 (local), Ubuntu 18.04 (remote)

When WorkspaceConfiguration.update() is used with ConfigurationTarget.Global to update a setting with machine scope, I expect the remote machine's global settings to be updated, but instead the local machine's settings are.

Steps to Reproduce:

  1. Create an extension with
// package.json
...
"contributes": {
  "configuration": {
    "type": "object",
    "title": "Example",
    "properties": {
      "foo.bar": {
        "type": "object",
        "scope": "machine"
      }
    }
  }
}
// extension.json
...
const config = vscode.workspace.getConfiguration('foo');
config.update('bar', {'test': 'object'}, vscode.ConfigurationTarget.Global);
  1. Run the extension in a remote workspace.

Expected result: "foo.bar": {"test": "object"} is written into the remote machine settings.

Actual result: it is written into the local machine's user settings (and shown grayed out in settings.json with a message "this setting cannot be applied in this window. It will be applied when you open a local window.")

Does this issue occur when all extensions are disabled?: No. (This requires using one of the remote development extensions for the issue to occur.)

@sandy081
Copy link
Member

/duplicate

microsoft/vscode-remote-release#1801

justinmk3 added a commit to aws/aws-toolkit-vscode that referenced this issue Aug 15, 2020
We can define a config value as "machine" scope.  But note the lack of
`vscode.ConfigurationTarget.Machine` scope, it is expected that we use
`vscode.ConfigurationTarget.Global`.  Then VSCode will resolve the
config value depending on "User" and "Remote" settings, and depending on
whether the current session is a Local or Remote instance.

NOTE:

- Current behavior of `scope=machine` is such that VSCode expects the
  user to enter a value: writeSetting() does not update the
  machine-local config.
- `scope=machine` has a known bug (issue is closed but NOT resolved):
  microsoft/vscode#102543
- Long-term solution is to use a passive warning combined with
  just-in-time detection, rather than fighting VSCode (and the user) to
  auto-update a user setting. if the user config value is invalid:
  #1242

REFERENCE:

For reference, `Workspace` and `WorkspaceFolder` scopes require
a workspace{folder} to write a setting, else writeSetting() fails:

    await this._configuration.writeSetting(k, detectedLocation, vscode.ConfigurationTarget.Workspace)

         2020-08-15 01:50:45 [ERROR]: failed to set config: 'samcli.location'='/home/linuxbrew/.linuxbrew/bin/sam',
         error: Error: Unable to write aws.samcli.location to Workspace Settings. This setting can be written only into User settings.
             at D.reject (file:///…/vs/workbench/workbench.desktop.main.js:5544:245)
             at D.resolveAndValidate (file:///…/vs/workbench/workbench.desktop.main.js:5547:622)
             at D.doWriteConfiguration (file:///…/vs/workbench/workbench.desktop.main.js:5541:414)
             at Object.factory (file:///…/vs/workbench/workbench.desktop.main.js:5541:190)
             at u.consume (file:///…/vs/workbench/workbench.desktop.main.js:130:421)
             at file:///…/vs/workbench/workbench.desktop.main.js:130:236
             at new Promise (<anonymous>)
             at u.queue (file:///…/vs/workbench/workbench.desktop.main.js:130:160)
             at D.writeConfiguration (file:///…/vs/workbench/workbench.desktop.main.js:5541:175)
             at C.writeConfigurationValue (file:///…/vs/workbench/workbench.desktop.main.js:5569:356)
             at file:///…/vs/workbench/workbench.desktop.main.js:5557:594
             at processTicksAndRejections (internal/process/task_queues.js:85:5) {
           name: 'Error',
           message: 'Unable to write aws.samcli.location to Workspace ' +
             'Settings. This setting can be written only into User ' +
             'settings.'
         }

    await this._configuration.writeSetting(k, detectedLocation, vscode.ConfigurationTarget.WorkspaceFolder)

         2020-08-15 01:50:45 [ERROR]: failed to set config: 'samcli.location'='/home/linuxbrew/.linuxbrew/bin/sam',
         error: Error: Unable to write to Folder Settings because no resource is provided.
             at D.reject (file:///…/vs/workbench/workbench.desktop.main.js:5544:245)
             at D.resolveAndValidate (file:///…/vs/workbench/workbench.desktop.main.js:5547:673)
             at D.doWriteConfiguration (file:///…/vs/workbench/workbench.desktop.main.js:5541:414)
             at Object.factory (file:///…/vs/workbench/workbench.desktop.main.js:5541:190)
             at u.consume (file:///…/vs/workbench/workbench.desktop.main.js:130:421)
             at file:///…/vs/workbench/workbench.desktop.main.js:130:236
             at new Promise (<anonymous>)
             at u.queue (file:///…/vs/workbench/workbench.desktop.main.js:130:160)
             at D.writeConfiguration (file:///…/vs/workbench/workbench.desktop.main.js:5541:175)
             at C.writeConfigurationValue (file:///…/vs/workbench/workbench.desktop.main.js:5569:356)
             at file:///…/vs/workbench/workbench.desktop.main.js:5557:594
             at processTicksAndRejections (internal/process/task_queues.js:85:5) {
           name: 'Error',
           message: 'Unable to write to Folder Settings because no resource is provided.'
         }
@github-actions github-actions bot locked and limited conversation to collaborators Aug 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*duplicate Issue identified as a duplicate of another issue(s)
Projects
None yet
Development

No branches or pull requests

4 participants
@roblourens @sandy081 @joelspadin-garmin and others