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

dap-node setup seems broken #554

Closed
barisere opened this issue Jan 26, 2022 · 26 comments
Closed

dap-node setup seems broken #554

barisere opened this issue Jan 26, 2022 · 26 comments

Comments

@barisere
Copy link

First, thank you to all the contributors for this extension. It has kept me from switching to VS Code.

I am unable to set up dap-node. It seems that the extension downloaded is broken. The logs from the Messages buffer show that the ZIP file is empty, and I confirmed that in my file manager.

dap-node: ms-vscode.node-debug2 debug extension are not set. You can download it with M-x dap-node-setup
Contacting host: marketplace.visualstudio.com:443
uncompressing publicsuffix.txt.gz...done
Wrote /tmp/ext83ZK7l.zip
[/tmp/ext83ZK7l.zip]
  End-of-central-directory signature not found.  Either this file is not
  a zipfile, or it constitutes one disk of a multi-part archive.  In the
  latter case the central directory and zipfile comment will be found on
  the last disk(s) of this archive.
unzip:  cannot find zipfile directory in one of /tmp/ext83ZK7l.zip or
        /tmp/ext83ZK7l.zip.zip, and cannot find /tmp/ext83ZK7l.zip.ZIP, period.
dap-node: Downloading done!

I'm be happy to provide more information if needed.

@yyoncho
Copy link
Member

yyoncho commented Jan 26, 2022

This is dos protection. Issue should go away after some time.

@mihaiolteanu
Copy link

My dap-chrome-setup, for example, did not work as well after switching to a new laptop and reinstalling everything. It returns nil but the folder is empty. I've had to manually copy the folder from the old pc. Maybe it is related?!

@barisere
Copy link
Author

@mihaiolteanu it is related. I fixed it by downloading the extension manually and extracting it in the destination directory.

@abougouffa
Copy link
Contributor

abougouffa commented Feb 4, 2022

I got the same issue when running the dap-gdb-lldb-setup command, I tracked it down and it seems that the problem is the generated URL in dap-utils-get-vscode-extension:

dap-mode/dap-utils.el

Lines 70 to 78 in 76cad34

(defun dap-utils-get-vscode-extension (publisher name &optional version path)
"Get vscode extension from PUBLISHER named NAME.
VERSION is the version of the extenssion, otherwise the latest.
PATH is the download destination dir."
(let* ((version (or version "latest"))
(url (format dap-utils-vscode-ext-url publisher name version))
(dest (or path
(f-join dap-utils-extension-path "vscode" (concat publisher "." name)))))
(dap-utils--get-extension url dest)))

For me, the generated URL was: https://marketplace.visualstudio.com/_apis/public/gallery/publishers/webfreak/vsextensions/debug/latest/vspackage), the get(URL) returns either this response:

{"$id":"1","innerException":null,"message":"Request was blocked due to exceeding usage of resource 'Count' in namespace 'AnonymousId'. For more information on why your request was blocked, see the topic \"Rate limits\" on the Microsoft Web site (https://go.microsoft.com/fwlink/?LinkId=823950).","typeName":"Microsoft.TeamFoundation.Framework.Server.RequestBlockedException, Microsoft.TeamFoundation.Framework.Server","typeKey":"RequestBlockedException","errorCode":0,"eventId":3000}

Or this one:

{"$id":"1","innerException":null,"message":"TF400898: An Internal Error Occurred. Activity Id: e15a6fba-431f-4173-9cc3-cc75cfc27a0c.","typeName":"System.NullReferenceException, mscorlib","typeKey":"NullReferenceException","errorCode":0,"eventId":0}

I think the dap-utils-get-vscode-extension needs to be rewritten to emulate a normal download behavior (with some cookies management or something like that).

@tl072
Copy link

tl072 commented May 3, 2022

This issue persists. I came to the same conclusion as @abougouffa by following the broken url. I have updated dap-mode just now and the problem is still there.

@allentiak
Copy link

@barisere said:

I fixed it by downloading the extension manually and extracting it in the destination directory.

I'm experiencing the same problem...
@barisere To which directory are you referring to?

@barisere
Copy link
Author

barisere commented May 5, 2022 via email

@allentiak
Copy link

@barisere Thanks. I cannot find that directory in my ~/.emacs.d, though...

@abougouffa
Copy link
Contributor

abougouffa commented May 6, 2022

@allentiak In my machine (I'm using Doom Emacs), the directory for a DAP extension (cpptools for example), is:
~/.emacs.d/.local/etc/dap-extension/vscode/cpptools

To find the destination directory on your machine, try to M-x eval-expression then evaluate the dap-utils-extension-path variable, it should point to the destination directory.

If you cannot install the DAP extension automatically using dap-***-setup commands, you can do it manually:

  1. First, you need to find the destination directory in your Emacs installation, (M-x eval-expression then type dap-utils-extension-path),
  2. Then you need to go to the extension's page on Visual Studio Marketplace (example for cpptools: marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools).
  3. From the Marketplace, download the extension for your OS,
  4. Go to DAP's destination directory, make a directory with the extension name, mkdir cpptools for cpptools, then extract the downloaded extension inside that directory cd cpptools ; unzip ~/Downloads/ms-vscode.cpptools-1.10.0.vsix
  5. Now, you should be able to use DAP with the installed extension inside Emacs.

@allentiak
Copy link

allentiak commented May 6, 2022

@abougouffa Thank you for your quick reply!

  1. First, you need to find the destination directory in your Emacs installation, (M-x eval-expression then type dap-utils-extension-path),

I tried this, with no avail. Twice, both with and without parenthesis.

In both cases, I got the following:

helm-M-x-execute-command: Symbol’s function definition is void: dap-utils-extension-path

Just in case, I made sure to add the dap package to my init.el. Even then, the package won't show up, either in the installed list, or in the list of packages to install...

Maybe I am missing a package, or something else?

@abougouffa
Copy link
Contributor

@allentiak Hello,

I see that you are using Spacemacs, I don't know too much about how it loads packages, but I think it won't load the package until you launch a command.

Try to open a project or a buffer, then launch a debug session (on Spacemacs, I think it is SPC d), It can complains about not founding the extension or something like that, but at the end, it should load the package. So after that you can evaluate dap-utils-extension-path variable (you won't need the parenthesis because it is not a function).

@allentiak
Copy link

allentiak commented May 6, 2022

@abougouffa
Thanks again for your patience.

Actually, that's the first thing I ever tried...

SPC d d d (debug --> debugging --> dap-debug)

Then, I get to choose the configuration template. I choose mine (see code below).

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "chrome",
            "request": "launch",
            "name": "DAP clojurescript",
            "url": "http://localhost:3000",
            "sourceMaps": true,
            "webRoot": "${workspaceFolder}",
            "sourceMapPathOverrides": {
                "*": "${workspaceFolder}/src/*"
            }
        }
    ]
}

First, I get the following error:

user-error: Have you loaded the ‘chrome’ specific dap package

Then, when I try evaluating the symbol, I get the following

helm-M-x-execute-command: Symbol’s value as variable is void: dap-utils-extension-path

The strangest of all is that I get the following in the lsp-log buffer:

Found the following clients for [~/path/to/an/open/test/file.clj] (server-id clojure-lsp, priority 0)
The following clients were selected based on priority: (server-id clojure-lsp, priority 0)
This server does not support foldingRangeProvider
Cancelling codeLens/resolve(157) in hook after-change-functions
Cancelling codeLens/resolve(156) in hook after-change-functions
Cancelling textDocument/codeAction(154) in hook after-change-functions
Cancelling textDocument/codeLens(164) in hook after-change-functions
Cancelling textDocument/codeAction(163) in hook after-change-functions
Cancelling textDocument/hover(330) in hook after-change-functions
Cancelling textDocument/documentHighlight(329) in hook after-change-functions
Cancelling textDocument/codeAction(328) in hook after-change-functions
Cancelling textDocument/codeLens(453) in hook after-change-functions
Cancelling textDocument/documentHighlight(451) in hook after-change-functions
Cancelling textDocument/codeAction(450) in hook after-change-functions
Cancelling textDocument/codeAction(455) in hook after-change-functions
Cancelling textDocument/codeLens(456) in hook after-change-functions
Cancelling textDocument/codeLens(464) in hook after-change-functions
Cancelling textDocument/codeAction(463) in hook after-change-functions
Cancelling textDocument/codeLens(496) in hook after-change-functions
Cancelling textDocument/codeAction(495) in hook after-change-functions
Cancelling textDocument/codeLens(523) in hook after-change-functions
Cancelling textDocument/codeAction(522) in hook after-change-functions
Cancelling textDocument/codeAction(880) in hook post-command-hook

@allentiak
Copy link

@yyoncho Any ideas about what all this could mean?

@RyanCargan
Copy link

RyanCargan commented May 16, 2022

@allentiak This page mentions needing (require 'dap-chrome) before you call dap-chrome-setup or do the manual equivalent. I'm assuming that's what

user-error: Have you loaded the ‘chrome’ specific dap package

is trying to tell you.
Adding that to theuser-config section in your .spacemacs file (or whatever it's called) should be enough if that's actually the problem:

(require 'dap-chrome)

Then doing the manual extension installation might work.

@allentiak
Copy link

@RyanCargan Thanks for your information! Unfortunately, I haven't been able to set this up...
I'm opening a bug in Spacemacs that refers to this one.

@EdwardIII
Copy link

Going back to the original post (dap-node-setup downloading an empty .zip file), I have a fix.

tl;dr: Here's how to fix the error:

  End-of-central-directory signature not found.  Either this file is not
  a zipfile, or it constitutes one disk of a multi-part archive.  In the
  latter case the central directory and zipfile comment will be found on
  the last disk(s) of this archive.
unzip:  cannot find zipfile directory in one of /tmp/ext4fqBxX.zip or
        /tmp/ext4fqBxX.zip.zip, and cannot find /tmp/ext4fqBxX.zip.ZIP, period.
  1. Clone (https://github.com/microsoft/vscode-node-debug2)
  2. Build the visual studio package with npm install && npm run package, this will output something like ./node-debug2-1.43.0.vsix
  3. Unzip that into the relevant location, e.g. unzip *.vsix -d ~/.emacs.d/.extension/vscode/ms-vscode.node-debug2
  4. Done, debugging now works.

Why?

it looks like the zip is empty because dap-node-setup tries to download this file:

https://marketplace.visualstudio.com/_apis/public/gallery/publishers/ms-vscode/vsextensions/node-debug2/latest/vspackage

Which returns an error message, rather than a file

{
  "$id": "1",
  "innerException": null,
  "message": "TF400898: An Internal Error Occurred. Activity Id: 9e6b5206-55c3-449b-b788-488a194ff230.",
  "typeName": "System.NullReferenceException, mscorlib",
  "typeKey": "NullReferenceException",
  "errorCode": 0,
  "eventId": 0
}

When I try and search for the package node-debug2, it doesn't seem to exist:

https://marketplace.visualstudio.com/search?term=node-debug2&target=VS&category=All%20categories&vsVersion=&sortBy=Relevance

I found this repo: https://github.com/microsoft/vscode-node-debug2
which says: "This repository has been archived by the owner. It is now read-only. ". Reading through the text it sounds like they now bundle this into vscode, and this library is deprecated? So not sure what the long term fix is.

I did try building the new extension it links to: https://github.com/microsoft/vscode-js-debug/
but that no longer contains nodeDebug.js so doesn't work with dap-node.

@allentiak
Copy link

allentiak commented Jul 9, 2022

UPDATE: The Chrome extension seems to download fine now :-)

(However, nor the Firefox nor the Node ones can be downloaded. Haven't tried the Edge extension,though...)

@4lph4-Ph4un
Copy link

I can confirm this is broken and not an issue about dos protection.

@acanimal
Copy link

As @EdwardIII suggest the vscode extension node-debug2 is no longer available and the new one is js-debug-nightly.

@danilevy1212
Copy link

Is the solution to this to move dap-node to use js-debug-nightly instead?

@eeshugerman
Copy link

@danilevy1212 Yes, see #369.

In the meantime you can manually build and install node-debug2, as described above: #554 (comment).

@danilevy1212
Copy link

Thank you!

@yyoncho
Copy link
Member

yyoncho commented Dec 27, 2022

It should be good after #700

We should migrate other packages as well (whenever possible).

@yyoncho yyoncho closed this as completed Dec 27, 2022
@lvguedes
Copy link

The URL seems broken again. When I execute M-x dap-node-setup I get the following message: url-http--insert-file-helper: https://open-vsx.org/api/ms-vscode/node-debug2/latest/: Not found. Maybe the definitive solution is to change the elisp command to clone and compile the repository just as @EdwardIII has done above. At least clone and compile when the main download URL fail.

Going back to the original post (dap-node-setup downloading an empty .zip file), I have a fix.

tl;dr: Here's how to fix the error:

  End-of-central-directory signature not found.  Either this file is not
  a zipfile, or it constitutes one disk of a multi-part archive.  In the
  latter case the central directory and zipfile comment will be found on
  the last disk(s) of this archive.
unzip:  cannot find zipfile directory in one of /tmp/ext4fqBxX.zip or
        /tmp/ext4fqBxX.zip.zip, and cannot find /tmp/ext4fqBxX.zip.ZIP, period.
1. Clone (https://github.com/microsoft/vscode-node-debug2)

2. Build the visual studio package with `npm install && npm run package`, this will output something like `./node-debug2-1.43.0.vsix`

3. Unzip that into the relevant location, e.g. `unzip *.vsix -d ~/.emacs.d/.extension/vscode/ms-vscode.node-debug2`

4. Done, debugging now works.

Why?

it looks like the zip is empty because dap-node-setup tries to download this file:

https://marketplace.visualstudio.com/_apis/public/gallery/publishers/ms-vscode/vsextensions/node-debug2/latest/vspackage

Which returns an error message, rather than a file

{
  "$id": "1",
  "innerException": null,
  "message": "TF400898: An Internal Error Occurred. Activity Id: 9e6b5206-55c3-449b-b788-488a194ff230.",
  "typeName": "System.NullReferenceException, mscorlib",
  "typeKey": "NullReferenceException",
  "errorCode": 0,
  "eventId": 0
}

When I try and search for the package node-debug2, it doesn't seem to exist:

https://marketplace.visualstudio.com/search?term=node-debug2&target=VS&category=All%20categories&vsVersion=&sortBy=Relevance

I found this repo: https://github.com/microsoft/vscode-node-debug2 which says: "This repository has been archived by the owner. It is now read-only. ". Reading through the text it sounds like they now bundle this into vscode, and this library is deprecated? So not sure what the long term fix is.

I did try building the new extension it links to: https://github.com/microsoft/vscode-js-debug/ but that no longer contains nodeDebug.js so doesn't work with dap-node.

@allentiak
Copy link

@lvguedes Assumming you cannot reopen this issue, I would suggest opening a new issue for this.

@sethidden
Copy link
Contributor

sethidden commented Nov 10, 2023

EDIT: It's now merged

Can you try the fix from here? #762
Just set the custom variable dap-utils-openvsx-extension-api-url to "https://open-vsx.org/api/%s/%s/%s" (no slash at end).

You can do it through just changing the value of the custom variable - no need to download the PR branch.

yyoncho pushed a commit that referenced this issue Nov 10, 2023
This change fixes this error when running `(dap-node-setup)`:
`url-insert-file-contents: https://open-vsx.org/api/ms-vscode/node-debug2/latest/: Not found`

The problem was that the OpenVSX URL template string had a trailing
slash, which is not handled by OpenVSX's Registry API Controller:
https://github.com/eclipse/openvsx/blob/master/server/src/main/java/org/eclipse/openvsx/RegistryAPI.java#L348

I can't really find a blame in the OpenVSX repo which could've caused
the extraneous trailing slash. Maybe the update to Java 17?

As you can see, there's no trailing slash at the end, so the route
doesn't get mached in the controller and causes a 404 Not Found.

Just removing the slash does the job and `(dap-node-setup)` runs successfully.

References:
- #554 (comment)
- #700
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests