Vscode: '${workspaceFolder}' can not be resolved in a multi folder workspace

Created on 9 Apr 2020  ·  17Comments  ·  Source: microsoft/vscode




  • VSCode Version: 1.44.0
  • OS Version: Windows 10 Pro 1909 Build 18363.720

Steps to Reproduce:

  1. Create a workspace
  2. Add a folder to that workspace.
  3. Add a launch configuration "Node.js: Attach to Process" in the workspace file.
  4. Start the debug session.

Here is my workspace file:

{
  "folders": [
        {
            "path": "."
        },
        {
            "path": "app"
        }
  ],
  "launch": {
    "configurations": [
      {
        "type": "node",
        "request": "attach",
        "name": "Attach by Process ID",
        "processId": "${command:PickProcess}",
        "skipFiles": [
          "<node_internals>/**"
        ]
      }

    ],
    "compounds": []
  },
  "settings": {}
}

Here is a screenshot of the error:

image


Does this issue occur when all extensions are disabled?: Yes

bug candidate debug regression verified

Most helpful comment

VS Code 1.44.2 (with node-debug 1.44.5) is out now. This should fix the issue.

All 17 comments

(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

I'm also seeing this in a workspace that already uses the : syntax; indeed, it still fails if I change the config to remove all workspaceFolder entirely.

I also have the problem under Win 7, VS Code 1.44 and I am not able to debug a remote node process. I don´t have any ${workspaceFolder} variable entry in my configuration. It is also a multi folder workspace. Furthermore I don´t have problems to debug with the Chrome debug plugin.

With 1.43 my debug configuration worked without any problems. So I am using the previous version right now,

I hope these informations are helpful.

Sounds like a regression, investigating...

After some investigation the problem is the following for the workspace configuration our debug extensions appends the following attribute
__workspaceFolder:'${workspaceFolder}'
And the configuration resolver properly tries to resolve this and complains becuase the scope of the folder is not specified. In a multi root workspace scope has to be specified, otherwise the resolver does not know against which folder to resolve the variables.

Proposed fix: the node extension which adds this attribute should scope it if it sees that we are in a multi root folder. So instead of ${workspaceFolder} use ${FOLDER_NAME:workspaceFolder}.

Forwarding to @roblourens and @connor4312 as they might know more about the changes in node debug. Adding label regression and candidate.

Looks similar to a problem I was going to report. I am doing simple Node.js debugging without folders or workspace. Things were working fine in 1.43.2 but when I upgraded to 1.44 I started seeing popup errors related to missing ${workspaceFolder}. Downgraded to 1.43.2 and the error went away. Most likely related to this.

@isidorn is the syntax really "${FOLDER_NAME:workspaceFolder}" and not the reversed order?

@weinand you are correct it is the reversed order as specified here https://code.visualstudio.com/docs/editor/variables-reference#_variables-scoped-per-workspace-folder

Oh. I think this is just so that we can apply defaults that contain ${workspaceFolder} but we won't be able to pick a default for multi-root workspaces.

I could just not add that property if we are in a multiroot workspace? And I guess it should fail in a nice way if there is a ${workspaceFolder} reference in a default that can't be resolved?

Is that right @connor4312 or do you remember if there's something else that I added this __workspaceFolder hack for?

Currently js-debug needs __workspaceFolder for quite a few things. I'll take a look at making those places optional/noop, if you need an interim fix you could pick the first workspace folder (should be no 'worse' than making js-debug no-op)

I've made changes in https://github.com/microsoft/vscode-js-debug/commit/4c29f9c08a59393e2a323dbbe2db1ac8ffe35e3b that should allow undefined workspace folders for attach. Launch will still need a workspace folder set; in js-debug I derive this as path.dirname(program) if there's none set.

I realized that previously we only set it when useV3 is set, now we set it all the time. I suggest that we just restore that setting check for the candidate.

Does anyone know of any temporary workaround that can be done locally until the fix has arrived?
I'm quite stuck.. can't run the debugger.

@axeldavid You can either downgrade Code itself to 1.43 or upgrade the node-debug extension to 1.44.5 by searching for ms-vscode.node-debug and selecting Manage > Install Another Version….

@axeldavid You can either downgrade Code itself to 1.43 or upgrade the node-debug extension to 1.44.5 by searching for ms-vscode.node-debug and selecting Manage > Install Another Version….

@zwaldowski Thanks a lot. I upgraded the node-debug extension and it works perfectly now.

VS Code 1.44.2 (with node-debug 1.44.5) is out now. This should fix the issue.

VS Code 1.44.2 (with node-debug 1.44.5) is out now. This should fix the issue.

Can confirm that the latest release has fixed this :+1:

Was this page helpful?
0 / 5 - 0 ratings