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

Installing on CentOS 6 failes with npm.taobao.org mirrors #1549

Closed
JLHwung opened this issue Jun 10, 2017 · 1 comment
Closed

Installing on CentOS 6 failes with npm.taobao.org mirrors #1549

JLHwung opened this issue Jun 10, 2017 · 1 comment
Labels
bugs Oh no, something's broken :-( installing node Issues with installing node/io.js versions. pull request wanted This is a great way to contribute! Help us out :-D

Comments

@JLHwung
Copy link
Contributor

JLHwung commented Jun 10, 2017

I will summary this bug in short and would like to discuss PR with you maintainers.

I use

NVM_NODEJS_ORG_MIRROR=http://npm.taobao.org/mirrors/node

setting to install node.js on a CentOS 6 server. The server is equipped with curl and libz support, so nvm will run

curl --compressed -q -L -s http://npm.taobao.org/mirrors/node/v6.11.0/node-v6.11.0.tar.xz -o blablabla.tar.xz

A simple call on http://npm.taobao.org/mirrors/node/v6.11.0/node-v6.11.0.tar.xz will looks like

< HTTP/1.1 302 Found
< Server: nginx/1.4.6 (Ubuntu)
< Date: Sat, 10 Jun 2017 07:00:57 GMT
< Content-Type: text/html; charset=utf-8
< Transfer-Encoding: chunked
< Connection: keep-alive
< Vary: Accept-Encoding
< Location: http://cdn.npm.taobao.org/dist/node/v6.11.0/node-v6.11.0.tar.xz
< Content-Encoding: deflate
< X-Response-Time: 5
< Strict-Transport-Security: max-age=15768000
<
* Curl_http_done: called premature == 0
* Connection #0 to host 127.0.0.1 left intact
Redirecting to <a href="http://cdn.npm.taobao.org/dist/node/v6.11.0/node-v6.11.0.tar.xz">http://cdn.npm.taobao.org/dist/node/v6.11.0/node-v6.11.0.tar.xz</a>.%

so npm.taobao.org will redirect to cdn.npm.taobao.org.

However, the built-in curl version of CentOS 6 is 7.19.7 (as of OP posting date), as is mentioned on curl changelog about 7.21.0, a bug is fixed namely

ignore response-body on redirect even if compressed

So what happen is curl 7.19.7 will prepend the response-body Redirecting to <a href="http://cdn.npm.taobao.org/dist/node/v6.11.0/node-v6.11.0.tar.xz">http://cdn.npm.taobao.org/dist/node/v6.11.0/node-v6.11.0.tar.xz</a>. to the binary tar.xz which causes a checksum mismatch on installing each time.

Here is the proposed PR solution, I can work on a PR if we agree on the solution.

  1. add nvm_curl_version routine to detect curl version
  2. use predicates nvm_curl_libz_support as well as nvm_version_greater_than_or_equal_to curl_version 7.21.0 to determine whether we need --compressed option.

Here is the reports routine but I am afraid it would not offer more information on this issue.

  • Operating system and version: CentOS 6.7 (Final)

  • nvm debug output:

nvm debug
nvm --version: v0.33.2
$SHELL: /bin/bash
$HOME: /root
$NVM_DIR: '$HOME/.nvm'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
$NVM_NODEJS_ORG_MIRROR: 'http://cdn.npm.taobao.org/dist/node'
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)'
uname -a: 'Linux 3.10.0-229.el7.x86_64 #1 SMP Fri Mar 6 11:36:42 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux'
OS version: CentOS release 6.7 (Final)
sed: -e expression #1, char 9: Unmatched ) or \)
curl: , curl 7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.27.1 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
wget: /usr/bin/wget, GNU Wget 1.12 built on linux-gnu.
git: /usr/bin/git, git version 1.7.1
nvm current: system
which node: /usr/local/bin/node
which iojs: which: no iojs in (/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:$HOME/bin)
which npm: /usr/local/bin/npm
npm config get prefix: /usr/local
npm root -g: /usr/local/lib/node_modules
  • nvm ls output:
nvm ls

->       system
default -> 6 (-> N/A)
node -> stable (-> N/A) (default)
iojs -> N/A (default)
lts/* -> lts/boron (-> N/A)
lts/argon -> v4.8.3 (-> N/A)
lts/boron -> v6.11.0 (-> N/A)
  • How did you install nvm? (e.g. install script in readme, homebrew): readme

  • What steps did you perform? nvm install 6

  • What happened? It keeps complaining before it fails finally.

Computing checksum with sha256sum
Checksums do not match: '6586cd79e959ca0b64dc3ecc722e906db668739103e7ef5b9db23b441e80c1c5' found, '2f0c0833a1dc0d1d52ef42d275d40125c5163bf92d2a663139beef70896f544d' expected.

  • What did you expect to happen?
    Installation succeeds.

  • Is there anything in any of your profile files (.bashrc, .bash_profile, .zshrc, etc) that modifies the PATH?
    nope

  • If you are having installation issues, or getting "N/A", what does curl -I --compressed -v https://nodejs.org/dist/ print out?
* About to connect() to nodejs.org port 443 (#0)
*   Trying 104.20.22.46... connected
* Connected to nodejs.org (104.20.22.46) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* SSL connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate:
* 	subject: CN=*.nodejs.org,OU=PositiveSSL Wildcard,OU=Domain Control Validated
* 	start date: Nov 08 00:00:00 2015 GMT
* 	expire date: Aug 22 23:59:59 2017 GMT
* 	common name: *.nodejs.org
* 	issuer: CN=COMODO RSA Domain Validation Secure Server CA,O=COMODO CA Limited,L=Salford,ST=Greater Manchester,C=GB
> HEAD /dist/ HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.27.1 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: nodejs.org
> Accept: */*
> Accept-Encoding: deflate, gzip
>
< HTTP/1.1 200 OK
HTTP/1.1 200 OK
< Date: Sat, 10 Jun 2017 06:54:36 GMT
Date: Sat, 10 Jun 2017 06:54:36 GMT
< Content-Type: text/html
Content-Type: text/html
< Connection: keep-alive
Connection: keep-alive
< Set-Cookie: __cfduid=d39e0047be613879188e1015d3e3607231497077676; expires=Sun, 10-Jun-18 06:54:36 GMT; path=/; domain=.nodejs.org; HttpOnly
Set-Cookie: __cfduid=d39e0047be613879188e1015d3e3607231497077676; expires=Sun, 10-Jun-18 06:54:36 GMT; path=/; domain=.nodejs.org; HttpOnly
< CF-Cache-Status: HIT
CF-Cache-Status: HIT
< Vary: Accept-Encoding
Vary: Accept-Encoding
< Expires: Sat, 10 Jun 2017 10:54:36 GMT
Expires: Sat, 10 Jun 2017 10:54:36 GMT
< Cache-Control: public, max-age=14400
Cache-Control: public, max-age=14400
< Server: cloudflare-nginx
Server: cloudflare-nginx
< CF-RAY: 36ca6b97fe9522b2-LAX
CF-RAY: 36ca6b97fe9522b2-LAX
< Content-Encoding: gzip
Content-Encoding: gzip

<
* Connection #0 to host nodejs.org left intact
* Closing connection #0
@JLHwung JLHwung changed the title Installing on CentOS 6 failed with npm.taobao.org mirrors Installing on CentOS 6 failes with npm.taobao.org mirrors Jun 10, 2017
@ljharb
Copy link
Member

ljharb commented Jun 10, 2017

I think your suggestion makes perfect sense!

We should make a new function so that both instances that currently use nvm_curl_libz_support can instead call into this new function to determine if the compressed flag can be used.

@ljharb ljharb added bugs Oh no, something's broken :-( installing node Issues with installing node/io.js versions. pull request wanted This is a great way to contribute! Help us out :-D labels Jun 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugs Oh no, something's broken :-( installing node Issues with installing node/io.js versions. pull request wanted This is a great way to contribute! Help us out :-D
Projects
None yet
Development

No branches or pull requests

2 participants