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

VS Code is unable to activate a debugger extension because of path casing discrepancies #118562

Closed
bobbrow opened this issue Mar 9, 2021 · 32 comments
Assignees
Labels
candidate Issue identified as probable candidate for fixing in the next release important Issue identified as high-priority regression Something that used to work is now broken verified Verification succeeded

Comments

@bobbrow
Copy link
Member

bobbrow commented Mar 9, 2021

  • VS Code Version: 1.54.1
  • OS Version: Windows 10 19041

More information here: microsoft/vscode-cpptools#7114

I want to highlight this from the customer's logs. They are trying to load the ms-vscode.cpptools extension, but the reasoning in the log does not make sense because ms-vscode.cpptools registers the 'cppvsdbg' debugger type). Downgrading VS Code to 1.53.2 fixes the issue for the customer. We're not sure what would cause this.

[2021-03-05 16:49:27.882] [exthost] [error] Activating extension ms-vscode.cpptools failed due to an error:
[2021-03-05 16:49:27.886] [exthost] [error] Error: a DebugAdapterDescriptorFactory can only be registered from the extension that defines the 'cppvsdbg' debugger.
	at m.registerDebugAdapterDescriptorFactory (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:91:25505)
	at Object.registerDebugAdapterDescriptorFactory (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:95:37807)
	at Object.initialize (c:\Users\sesa404214\.vscode\extensions\ms-vscode.cpptools-1.2.2\dist\main.js:18300:35)
	at c:\Users\sesa404214\.vscode\extensions\ms-vscode.cpptools-1.2.2\dist\main.js:26903:27
	at Generator.next (<anonymous>)
	at c:\Users\sesa404214\.vscode\extensions\ms-vscode.cpptools-1.2.2\dist\main.js:26841:71
	at new Promise (<anonymous>)
	at module.exports.__awaiter (c:\Users\sesa404214\.vscode\extensions\ms-vscode.cpptools-1.2.2\dist\main.js:26837:12)
	at activate (c:\Users\sesa404214\.vscode\extensions\ms-vscode.cpptools-1.2.2\dist\main.js:26870:12)
	at Function._callActivateOptional (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:91:14037)
	at Function._callActivate (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:91:13714)
	at c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:91:11746
	at processTicksAndRejections (internal/process/task_queues.js:97:5)

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

@michalfita
Copy link

I'm affected.

@sean-mcmanus
Copy link
Contributor

@vscodebot It doesn't appear to be a duplicate.

@fabioz
Copy link
Contributor

fabioz commented Mar 10, 2021

I'm seeing the same issue (in my case the extension has a debugger registered in the package.json:

"debuggers": [
    {
        "type": "robotframework-lsp",
        "label": "Robot Framework",
        "languages": [
            "robotframework"
        ],
     ...

And later the call:

	debug.registerDebugAdapterDescriptorFactory('robotframework-lsp', {
		createDebugAdapterDescriptor: session => {
			let env = session.configuration.env;
			let target = session.configuration.target;
			return createDebugAdapterExecutable(env, target);
		}
	});

fails with:

[2021-03-10 11:30:11.612] [exthost] [error] Error: a DebugAdapterDescriptorFactory can only be registered from the extension that defines the 'robotframework-lsp' debugger.
	at m.registerDebugAdapterDescriptorFactory (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:91:25505)
	at Object.registerDebugAdapterDescriptorFactory (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:95:37807)
	at registerDebugger (x:\vscode-robot\robotframework-lsp\robotframework-ls\vscode-client\out\extension.js:197:20)
	at x:\vscode-robot\robotframework-lsp\robotframework-ls\vscode-client\out\extension.js:346:13
	at Generator.next (<anonymous>)
	at fulfilled (x:\vscode-robot\robotframework-lsp\robotframework-ls\vscode-client\out\extension.js:23:58)

Windows 10
VSCode version: 1.54.1

@fabioz
Copy link
Contributor

fabioz commented Mar 10, 2021

As a note, downgrading VSCode to 1.53.2 also works for me (so, it seems like a regression in the latest release).

@sandy081 sandy081 assigned alexdima and unassigned sandy081 Mar 11, 2021
@alexdima alexdima assigned weinand and isidorn and unassigned alexdima Mar 11, 2021
@weinand weinand added debug Debug viewlet, configurations, breakpoints, adapter issues bug Issue identified by VS Code Team member as probable bug important Issue identified as high-priority labels Mar 11, 2021
@weinand
Copy link
Contributor

weinand commented Mar 11, 2021

Here is my analysis of the issue:

The error occurs because a check in the extension API fails that verifies that a "debug adapter factory" can only be registered in the extension that defines the corresponding "debugger".

The error occurs here:

if (!this.definesDebugType(extension, type)) {
throw new Error(`a DebugAdapterDescriptorFactory can only be registered from the extension that defines the '${type}' debugger.`);
}

Here is the code of the "check":

private definesDebugType(ed: IExtensionDescription, type: string) {
if (ed.contributes) {
const debuggers = <IDebuggerContribution[]>ed.contributes['debuggers'];
if (debuggers && debuggers.length > 0) {
for (const dbg of debuggers) {
// only debugger contributions with a "label" are considered a "defining" debugger contribution
if (dbg.label && dbg.type) {
if (dbg.type === type) {
return true;
}
}
}
}
}
return false;
}

An example context where this check fails can be seen above in this #118562 (comment):

A debugger with type "robotframework-lsp" is defined in the package.json and in the extension's activation code a debug adapter factory is registered for the same type "robotframework-lsp" with the call debug.registerDebugAdapterDescriptorFactory('robotframework-lsp', <factory>).

The check fails which means that the IExtensionDescription does not seem to contain the correct data.

This check exists for a long time and never failed for any other reason than the one it was introduced for.

I'm not aware of any changes in debug land that could cause this (there were no changes in that area).

Until now, this issue was only reported for Windows.

@alexdima @sandy081 @bpasero @isidorn are you aware of anything related to this?

@weinand weinand added regression Something that used to work is now broken and removed bug Issue identified by VS Code Team member as probable bug labels Mar 11, 2021
@alexdima
Copy link
Member

alexdima commented Mar 11, 2021

Thank you @weinand , that helped to point in the right direction. Looking again at the full logs contained in the original issue, the problem is that the require('vscode') call is not identified as coming from the C++ extension:

@jrieken It looks like an uppercase/lowercase problem (sesa404214 vs SESA404214):

Relevant lines:

Could not identify extension for 'vscode' require call from 
c:\Users\sesa404214\.vscode\extensions\ms-vscode.cpptools-1.2.2\dist\main.js
c:\Users\SESA404214\.vscode\extensions\ms-vscode.cpptools-1.2.2 -> ms-vscode.cpptools
Full relevant logs:
[2021-03-05 16:49:27.182] [exthost] [info] ExtensionService#loadCommonJSModule file:///c:/Users/sesa404214/.vscode/extensions/ms-vscode.cpptools-1.2.2/dist/main
[2021-03-05 16:49:27.321] [exthost] [warning] Could not identify extension for 'vscode' require call from c:\Users\sesa404214\.vscode\extensions\ms-vscode.cpptools-1.2.2\dist\main.js. These are the extension path mappings: 
	c:\Program Files\Microsoft VS Code\resources\app\extensions\configuration-editing -> vscode.configuration-editing
	c:\Program Files\Microsoft VS Code\resources\app\extensions\css-language-features -> vscode.css-language-features
	c:\Program Files\Microsoft VS Code\resources\app\extensions\debug-auto-launch -> vscode.debug-auto-launch
	c:\Program Files\Microsoft VS Code\resources\app\extensions\debug-server-ready -> vscode.debug-server-ready
	c:\Program Files\Microsoft VS Code\resources\app\extensions\emmet -> vscode.emmet
	c:\Program Files\Microsoft VS Code\resources\app\extensions\extension-editing -> vscode.extension-editing
	c:\Program Files\Microsoft VS Code\resources\app\extensions\git -> vscode.git
	c:\Program Files\Microsoft VS Code\resources\app\extensions\git-ui -> vscode.git-ui
	c:\Program Files\Microsoft VS Code\resources\app\extensions\github -> vscode.github
	c:\Program Files\Microsoft VS Code\resources\app\extensions\github-authentication -> vscode.github-authentication
	c:\Program Files\Microsoft VS Code\resources\app\extensions\grunt -> vscode.grunt
	c:\Program Files\Microsoft VS Code\resources\app\extensions\gulp -> vscode.gulp
	c:\Program Files\Microsoft VS Code\resources\app\extensions\html-language-features -> vscode.html-language-features
	c:\Program Files\Microsoft VS Code\resources\app\extensions\image-preview -> vscode.image-preview
	c:\Program Files\Microsoft VS Code\resources\app\extensions\jake -> vscode.jake
	c:\Program Files\Microsoft VS Code\resources\app\extensions\json-language-features -> vscode.json-language-features
	c:\Program Files\Microsoft VS Code\resources\app\extensions\markdown-language-features -> vscode.markdown-language-features
	c:\Program Files\Microsoft VS Code\resources\app\extensions\merge-conflict -> vscode.merge-conflict
	c:\Program Files\Microsoft VS Code\resources\app\extensions\microsoft-authentication -> vscode.microsoft-authentication
	c:\Program Files\Microsoft VS Code\resources\app\extensions\ms-vscode-remote.remote-wsl-recommender -> ms-vscode-remote.remote-wsl-recommender
	c:\Program Files\Microsoft VS Code\resources\app\extensions\ms-vscode.js-debug -> ms-vscode.js-debug
	c:\Program Files\Microsoft VS Code\resources\app\extensions\ms-vscode.js-debug-companion -> ms-vscode.js-debug-companion
	c:\Program Files\Microsoft VS Code\resources\app\extensions\ms-vscode.node-debug -> ms-vscode.node-debug
	c:\Program Files\Microsoft VS Code\resources\app\extensions\ms-vscode.node-debug2 -> ms-vscode.node-debug2
	c:\Program Files\Microsoft VS Code\resources\app\extensions\ms-vscode.references-view -> ms-vscode.references-view
	c:\Program Files\Microsoft VS Code\resources\app\extensions\ms-vscode.vscode-js-profile-table -> ms-vscode.vscode-js-profile-table
	c:\Program Files\Microsoft VS Code\resources\app\extensions\npm -> vscode.npm
	c:\Program Files\Microsoft VS Code\resources\app\extensions\php-language-features -> vscode.php-language-features
	c:\Program Files\Microsoft VS Code\resources\app\extensions\search-result -> vscode.search-result
	c:\Program Files\Microsoft VS Code\resources\app\extensions\simple-browser -> vscode.simple-browser
	c:\Program Files\Microsoft VS Code\resources\app\extensions\testing-editor-contributions -> vscode.testing-editor-contributions
	c:\Program Files\Microsoft VS Code\resources\app\extensions\typescript-language-features -> vscode.typescript-language-features
	c:\Users\SESA404214\.vscode\extensions\asabil.meson-1.3.0 -> asabil.meson
	c:\Users\SESA404214\.vscode\extensions\asciidoctor.asciidoctor-vscode-2.8.7 -> asciidoctor.asciidoctor-vscode
	c:\Users\SESA404214\.vscode\extensions\belfz.search-crates-io-1.2.1 -> belfz.search-crates-io
	c:\Users\SESA404214\.vscode\extensions\bierner.markdown-checkbox-0.1.3 -> bierner.markdown-checkbox
	c:\Users\SESA404214\.vscode\extensions\bungcip.better-toml-0.3.2 -> bungcip.better-toml
	c:\Users\SESA404214\.vscode\extensions\gruntfuggly.shifter-0.0.6 -> Gruntfuggly.shifter
	c:\Users\SESA404214\.vscode\extensions\jebbs.plantuml-2.14.3 -> jebbs.plantuml
	c:\Users\SESA404214\.vscode\extensions\matklad.rust-analyzer-0.2.505 -> matklad.rust-analyzer
	c:\Users\SESA404214\.vscode\extensions\ms-python.python-2021.2.582707922 -> ms-python.python
	c:\Users\SESA404214\.vscode\extensions\ms-toolsai.jupyter-2021.3.619093157 -> ms-toolsai.jupyter
	c:\Users\SESA404214\.vscode\extensions\ms-vscode-remote.remote-containers-0.163.0 -> ms-vscode-remote.remote-containers
	c:\Users\SESA404214\.vscode\extensions\ms-vscode-remote.remote-ssh-0.65.0 -> ms-vscode-remote.remote-ssh
	c:\Users\SESA404214\.vscode\extensions\ms-vscode-remote.remote-ssh-edit-0.65.0 -> ms-vscode-remote.remote-ssh-edit
	c:\Users\SESA404214\.vscode\extensions\ms-vscode-remote.remote-wsl-0.54.0 -> ms-vscode-remote.remote-wsl
	c:\Users\SESA404214\.vscode\extensions\ms-vscode.cmake-tools-1.6.0 -> ms-vscode.cmake-tools
	c:\Users\SESA404214\.vscode\extensions\ms-vscode.cpptools-1.2.2 -> ms-vscode.cpptools
	c:\Users\SESA404214\.vscode\extensions\ms-vscode.powershell-2021.2.2 -> ms-vscode.powershell
	c:\Users\SESA404214\.vscode\extensions\rust-lang.rust-0.7.8 -> rust-lang.rust
	c:\Users\SESA404214\.vscode\extensions\serayuzgur.crates-0.5.6 -> serayuzgur.crates
	c:\Users\SESA404214\.vscode\extensions\twxs.cmake-0.0.17 -> twxs.cmake
	c:\Users\SESA404214\.vscode\extensions\wakatime.vscode-wakatime-5.0.1 -> WakaTime.vscode-wakatime

@alexdima alexdima assigned jrieken and unassigned weinand and isidorn Mar 11, 2021
@weinand
Copy link
Contributor

weinand commented Mar 11, 2021

@alexdima wow, thanks a lot for connecting the dots!
@isidorn we are off the hook!

@bobbrow bobbrow changed the title VS Code is unable to activate the extension, but the reason is not correct VS Code is unable to activate the extension because of path casing discrepancies Mar 11, 2021
@bobbrow bobbrow changed the title VS Code is unable to activate the extension because of path casing discrepancies VS Code is unable to activate a debugger extension because of path casing discrepancies Mar 11, 2021
@jrieken
Copy link
Member

jrieken commented Mar 12, 2021

Maybe the same as https://github.com/microsoft/vscode-remote-release/issues/4602. I don't recall any changes and the code that builds the extension tree is quite old (mature). However, we did change the node version this milestone and maybe some things around realPath have changed

@jrieken
Copy link
Member

jrieken commented Mar 12, 2021

@michalfita thanks for reporting. This is a very interesting issue. A few questions

  • VS Code seems to be confused about the casing for the folder in which your extension live. What is the actual casing of your user folder: c:\Users\sesa404214 or c:\Users\SESA404214?
  • How do you start VS Code? From the command line? Iff so what case path & casing was used in the command line?

@michalfita
Copy link

In this case they were launched from the Start menu eventually a new windows from inside already running vscode if that matters.

@deepak1556
Copy link
Contributor

deepak1556 commented Mar 12, 2021

There is indeed electron minor version bump from 1.53.2 to 1.54.0 but there is no node version change and I have looked through the electron commits, nothing related to this code path in node was changed.

To rule out runtime effects, I updated 1.54 branch to same runtime as 1.53 and followed steps #118812 (comment), the issue was still reproducible. I also switched the runtime to use binaries from https://electronjs.org/ to rule out any internal patches.

So this is purely a regression on our app code, performing a git bisect now.

@deepak1556
Copy link
Contributor

b28cd23d521059938e08515618cdc670f3baa79b is the first bad commit
commit b28cd23d521059938e08515618cdc670f3baa79b
Author: Benjamin Pasero <benjpas@microsoft.com>
Date:   Wed Feb 3 11:29:26 2021 +0100

    fs - more removal of promisify utility

 src/vs/base/node/extpath.ts                                         | 5 ++---
 src/vs/base/node/pfs.ts                                             | 5 ++---
 src/vs/base/node/processes.ts                                       | 6 +++---
 src/vs/platform/files/node/diskFileSystemProvider.ts                | 4 ++--
 src/vs/workbench/api/node/extHostTunnelService.ts                   | 3 +--
 .../contrib/performance/electron-browser/startupTimings.ts          | 5 ++---
 src/vs/workbench/services/extensions/node/proxyResolver.ts          | 3 +--
 7 files changed, 13 insertions(+), 18 deletions(-)

@deepak1556
Copy link
Contributor

This is a fun one, the problematic call was the conversion from fs.realpath callback version to the promise version on line b28cd23#diff-505206763bd72133dfaa593fe504440c0d863477741e23d87ed706bca6aa8a57R55 . Node gives different results for these.

> fs.realpath('.\\vscode-oss\\vscode\\extensions\\microsoft-authentication\\out\\extension.js', (err, path) => console.log(path))
undefined
> A:\vscode-oss\vscode\extensions\microsoft-authentication\out\extension.js

>
> fs.promises.realpath('.\\vscode-oss\\vscode\\extensions\\microsoft-authentication\\out\\extension.js').then((path) => console.log(path))
Promise { <pending> }
> D:\github\vscode-subst\vscode-oss\vscode\extensions\microsoft-authentication\out\extension.js

@deepak1556
Copy link
Contributor

deepak1556 commented Mar 13, 2021

According to the docs, the promise version of realpath is equivalent to realpath.native. Hence the different results.

@bpasero bpasero assigned bpasero and unassigned jrieken Mar 13, 2021
@bpasero bpasero added this to the March 2021 milestone Mar 13, 2021
@bpasero bpasero removed the debug Debug viewlet, configurations, breakpoints, adapter issues label Mar 13, 2021
@bpasero
Copy link
Member

bpasero commented Mar 13, 2021

👏

@weinand
Copy link
Contributor

weinand commented Mar 13, 2021

@deepak1556 great work, thanks a lot!

@jrieken
Copy link
Member

jrieken commented Mar 15, 2021

wow, nice find @deepak1556

@bpasero
Copy link
Member

bpasero commented Mar 15, 2021

This fix has been pushed to main for insiders but also a recovery for Feb.

@bpasero bpasero closed this as completed Mar 15, 2021
@weinand
Copy link
Contributor

weinand commented Mar 15, 2021

The fix for this should also fix the following issues:

And maybe:

@deepak1556 deepak1556 added the verified Verification succeeded label Mar 15, 2021
@AnrDaemon
Copy link

Does it also fix #92945 and #112231 or they require a separate attention?

@weinand
Copy link
Contributor

weinand commented Mar 16, 2021

@AnrDaemon no, those two issues preceded the commit that resulted in this regression.

@SlurpTheo
Copy link

This is a fun one, the problematic call was the conversion from fs.realpath callback version to the promise version on line b28cd23#diff-505206763bd72133dfaa593fe504440c0d863477741e23d87ed706bca6aa8a57R55 . Node gives different results for these.

> fs.realpath('.\\vscode-oss\\vscode\\extensions\\microsoft-authentication\\out\\extension.js', (err, path) => console.log(path))
undefined
> A:\vscode-oss\vscode\extensions\microsoft-authentication\out\extension.js

>
> fs.promises.realpath('.\\vscode-oss\\vscode\\extensions\\microsoft-authentication\\out\\extension.js').then((path) => console.log(path))
Promise { <pending> }
> D:\github\vscode-subst\vscode-oss\vscode\extensions\microsoft-authentication\out\extension.js

Whoa, has an issue been filed with node? That promisify(fs.realpath)(path) behaves differently than fs.promises.realpath(path) (i.e., it performs like fs.realpath(path))?

@github-actions github-actions bot locked and limited conversation to collaborators Apr 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
candidate Issue identified as probable candidate for fixing in the next release important Issue identified as high-priority regression Something that used to work is now broken verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

15 participants