helm-dash icon indicating copy to clipboard operation
helm-dash copied to clipboard

Cannot retrieve list of official docsets

Open dchrzanowski opened this issue 6 years ago • 19 comments

I've narrowed down that helm-install-docset executes helm-dash-read-json-from-url that seems to fail to retrieve data from "https://api.github.com/repos/Kapeli/feeds/contents/" with the error: Wrong type argument: integer-or-marker-p, nil. Possibly a change in the way url-http-end-of-headers is set/not-set?

dchrzanowski avatar Feb 11 '19 21:02 dchrzanowski

This looks like a dup of #132. It is a connectivity issue trying to fetch that json.

I can't reproduce it in my machine, and even we could add some protection so it doesn't crash hard (PRs accepted), I'm not sure it'd solve the real issue.

kidd avatar Feb 12 '19 08:02 kidd

I'll try again today, see if there is problem in reproducing the error.

dchrzanowski avatar Feb 12 '19 09:02 dchrzanowski

Same problem here! Any suggestions?

buhudu avatar Feb 13 '19 01:02 buhudu

depending on your elisp debugging skills you can try to call edebug-defun on the breaking function and try to see why the variable url-http-end-of-headers is nil.

There's this reported bug https://emacs.stackexchange.com/questions/32950/why-isnt-url-http-end-of-headers-set-correctly-when-using-url-automatic-caching, but the behavior is different, so it being nil probably means we got no content at all from the request. But there's no reason why you're getting failures from downloading from that url.

kidd avatar Feb 14 '19 16:02 kidd

Yes I've already looked at this post from stack before. There really is no reason to not get any data back since the url is live.

dchrzanowski avatar Feb 14 '19 17:02 dchrzanowski

Weird, when I step through the debugger on url-retrieve in url.el I can get to the point where I select a docset to install. But then I get a "Bad URL" error.

Outside of the debugger I don't even make it to that step.

buhudu avatar Feb 15 '19 02:02 buhudu

That's some odd behaviour. My Elisp fu is not good enough to tackle this.

dchrzanowski avatar Feb 15 '19 08:02 dchrzanowski

It works. Thank you.

buhudu avatar Feb 18 '19 16:02 buhudu

Alternative:

You can also go to the list of feeds here. Click the desired xml file. Then download the tgz file from any of the url's from the xml file. Once you have the file downloaded, you can run M-x helm-dash-install-docset-from-file and point it to the downloaded file.

dchrzanowski avatar Feb 18 '19 16:02 dchrzanowski

Here's another alternative. I rewrote the function so that it uses curl but returns the same result. Works on my machine (TM)

(defun helm-dash-read-json-from-url (url)
  (shell-command (concat "curl -s " url) "*helm-dash-download*")
  (with-current-buffer "*helm-dash-download*"
    (json-read)))

kidd avatar Feb 18 '19 19:02 kidd

I've replaced all the URL functions with calls to curl, since it seems curl's proxy handling is a bit better than url.el's. The change is available here in the windows-fixes branch (should also work on Linux☺).

jeeger avatar Mar 04 '19 16:03 jeeger

I think that this a problem with url-retrieve-synchronously. This works:

(url-retrieve "https://api.github.com/repos/Kapeli/feeds/contents"
  (lambda (status) (switch-to-buffer (current-buffer)))))

As a side note, if we do want to switch to curl I think we should use request.el

jbaum98 avatar Mar 13 '19 00:03 jbaum98

I think that this a problem with url-retrieve-synchronously. This works:

(url-retrieve "https://api.github.com/repos/Kapeli/feeds/contents"
  (lambda (status) (switch-to-buffer (current-buffer)))))

Nope, this fails here as well.

As a side note, if we do want to switch to curl I think we should use request.el

Yes, that would make much more sense. I'm not familiar with request.el, but I'll have a look at it if my ad-hoc curl patching fails ☺.

jeeger avatar Mar 13 '19 09:03 jeeger

Nope, this fails here as well.

What do you mean by "here"? I just meant that evaluating that using eval-expression gives me a buffer with a response in it, whereas

(switch-to-buffer (url-retrieve-synchronously "https://api.github.com/repos/Kapeli/feeds/contents"))

doesn't work.

jbaum98 avatar Mar 13 '19 15:03 jbaum98

I mean that evaluating this expression does not return any content on this PC, since url.el is broken for using HTTPS over a proxy. This is why I've worked around url.el by using curl.

jeeger avatar Mar 13 '19 15:03 jeeger

Maybe I've misunderstood, but this makes me think that the proxy is not the issue. Because url-retrieve works for me even though url-retrieve-synchronously doesn't. So at least there are 2 issues: the proxy messes up everything, but even without the proxy I'm experiencing this issue with helm-dash.

jbaum98 avatar Mar 13 '19 18:03 jbaum98

Interesting, here it's definitely the proxy. request.el definitely looks like a good alternative here, maybe gated with an availability check so it's only used when installed.

jeeger avatar Mar 14 '19 08:03 jeeger

@jeeger , I'd buy into it if it's gated. I don't want to make an extra dependency for everyone.

Total naive question. Is a fix for proxy over http possible by plumbing some elisp? or we'd need hardcore networking knowledge for that? upstream emacs would benefit from this fix if we'd have it.

kidd avatar Mar 14 '19 13:03 kidd

I've had a look at the url.el elisp, and it's a tangled mess for me. I think that bug that might well have it's origin in the basic structure of url.el. TLS and Proxies are both kinds of "stream processors" that might not be able to be "stacked" recursively. I don't see me fixing url.el in the time I have available, even though it would of course be preferable to using an external package.

Using request.el would be much easier, and it could be easily gated behind a featurep invocation.

Edit: What makes this more complicated is that it seems this bug only occurs with redirects.

jeeger avatar Mar 14 '19 13:03 jeeger