hokaccha / nodebrew

Node.js version manager
MIT License
1.06k stars 66 forks source link

Fail to fetch source or binary with newest curl #63

Closed endaaman closed 7 years ago

endaaman commented 7 years ago

Hi. nodebrew is very useful and Im using this in several evironments but I encountered a problem so I will inform that here.

nodebrew fails to fetch source or binary. Here is my outputs

$ nodebrew install-binary 7
v7.7.3 is not found

Can not fetch: https://nodejs.org/dist/v7.7.3/node-v7.7.3-linux-x64.tar.gz

Im not familiar with perl but I tried to look at the source code and found that

https://github.com/hokaccha/nodebrew/blob/master/nodebrew#L472

this if statement is evaluated as falsy and

https://github.com/hokaccha/nodebrew/blob/master/nodebrew#L866

the result of curl command is unintended. Then when I tried the command that is excuted in nodebrew I got

$ curl -LIs "https://nodejs.org/dist/v7.7.3/node-v7.7.3-linux-x64.tar.gz"
HTTP/2 200
date: Sat, 18 Mar 2017 07:21:04 GMT
content-type: application/gzip
content-length: 15541113
set-cookie: __cfduid=dd187315094d80e345b3765c78feb60ad1489821664; expires=Sun, 18-Mar-18 07:21:04 GMT; path=/; domain=.nodejs.org; HttpOnly
last-modified: Tue, 14 Mar 2017 21:01:06 GMT
etag: "58c85a12-ed2379"
accept-ranges: bytes
server: cloudflare-nginx
cf-ray: 34166ed80fc36eb7-NRT

So I found the reason of the error is that the regexp /200 OK/ is not matched with HTTP/2 200. My curl (for Debian sid/unstable) version is 7.52.1.

$ curl --version
curl 7.52.1 (x86_64-pc-linux-gnu) libcurl/7.52.1 OpenSSL/1.0.2k zlib/1.2.8 libidn2/0.16 libpsl/0.17.0 (+libidn2/0.16) libssh2/1.8.0 nghttp2/1.19.0 librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets HTTPS-proxy PSL

I am glad if you fixed to make compatible as soon as possible. Regards.

msfm commented 7 years ago

I'm facing the same issue on fedora 25 coming with curl 7.51.0. It looks a trivial fix, so I've just sent PR #64.

hokaccha commented 7 years ago

@endaaman Please try nodebrew selfupdate and nodebrew install-binary 7. Thanks to @msfm

hokaccha commented 7 years ago

@endaaman Sorry, nodebrew selfupdate will be failed, because selfupdate uses curl 😓 You should re-install nodebrew with curl -L git.io/nodebrew | perl - setup.

msfm commented 7 years ago

I think nodebrew selfupdate works fine. Because selfupdate does not use fetch_able and it just fetches nodebrew from $nodebrew_url.

In fact, I executed nodebrew selfupdate and updating nodebrew worked fine on my environment (fedora 25).

hokaccha commented 7 years ago

@msfm Awesome 😍