nvm-sh / nvm

Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Source download fails with errors on Alpine Linux 3.17 Docker image

nilsstre opened this issue Β· comments

Hi πŸ˜„

Love nvm but I'm having issues installing Node from source in an Alpine Linux Docker image.

Operating system and version:

  • macOS Ventura - Version 13.0
  • Docker version 20.10.11, build dea9396

nvm debug output:

nvm --version: v0.39.2
$SHELL: /bin/ash
$SHLVL: 1
whoami: 'root'
${HOME}: /root
${NVM_DIR}: '/.nvm'
${PATH}: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
$PREFIX: ''
${NPM_CONFIG_PREFIX}: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''

nvm ls output:

N/A
iojs -> N/A (default)
node -> stable (-> N/A) (default)
unstable -> N/A (default)
lts/* -> lts/hydrogen (-> N/A)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.24.1 (-> N/A)
lts/erbium -> v12.22.12 (-> N/A)
lts/fermium -> v14.21.1 (-> N/A)
lts/gallium -> v16.18.1 (-> N/A)
lts/hydrogen -> v18.12.1 (-> N/A)

How did you install nvm?

I have installed nvm on a docker image using Alpine Linux 3.17 following the instructions in the README.

RUN mkdir -p $NVM_DIR && \
  apk add --update --no-cache curl bash ca-certificates openssl ncurses coreutils python3 make gcc g++ libgcc linux-headers grep util-linux binutils findutils && \
  curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash && \
  chmod +x $NVM_DIR/nvm.sh && \
  rm -rf /var/cache/apk/*

What steps did you perform?

I connected to the container using the command docker sh run --rm -it --entrypoint bash <image name> and tried to install Node v18.12.1 from source using the command sh nvm install -s v18.12.1 as described in the README.

What happened?

The command failed and outputted the following result:

bash: [: -ne: unary operator expected
bash: [: -eq: unary operator expected

I have tried install other versions of Node and gotten similar results.

Testing v16.18.1

bash: [: -ne: unary operator expected
bash: [: -ne: unary operator expected
bash: [: -ne: unary operator expected

Testing v14.21.1

bash: [: -ne: unary operator expected
bash: [: -eq: unary operator expected

What did you expect to happen?

The specified Node version being installed from source.

Is there anything in any of your profile files that modifies the PATH?

No.

If you are having installation issues, or getting "N/A", what does curl -I --compressed -v https://nodejs.org/dist/ print out?

*   Trying 104.20.23.46:443...
* Connected to nodejs.org (104.20.23.46) port 443 (#0)
* ALPN: offers h2
* ALPN: offers http/1.1
*  CAfile: /etc/ssl/certs/ca-certificates.crt
*  CApath: none
* TLSv1.0 (OUT), TLS header, Certificate Status (22):
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS header, Certificate Status (22):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS header, Finished (20):
* TLSv1.2 (IN), TLS header, Supplemental data (23):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.2 (OUT), TLS header, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS header, Supplemental data (23):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* ALPN: server accepted h2
* Server certificate:
*  subject: CN=*.nodejs.org
*  start date: Jan 11 00:00:00 2022 GMT
*  expire date: Feb 11 23:59:59 2023 GMT
*  subjectAltName: host "nodejs.org" matched cert's "nodejs.org"
*  issuer: C=GB; ST=Greater Manchester; L=Salford; O=Sectigo Limited; CN=Sectigo RSA Domain Validation Secure Server CA
*  SSL certificate verify ok.
* Using HTTP2, server supports multiplexing
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* TLSv1.2 (OUT), TLS header, Supplemental data (23):
* TLSv1.2 (OUT), TLS header, Supplemental data (23):
* TLSv1.2 (OUT), TLS header, Supplemental data (23):
* h2h3 [:method: HEAD]
* h2h3 [:path: /dist/]
* h2h3 [:scheme: https]
* h2h3 [:authority: nodejs.org]
* h2h3 [user-agent: curl/7.86.0]
* h2h3 [accept: */*]
* h2h3 [accept-encoding: deflate, gzip, br]
* Using Stream ID: 1 (easy handle 0x7f1f6d2a4a90)
* TLSv1.2 (OUT), TLS header, Supplemental data (23):
> HEAD /dist/ HTTP/2
> Host: nodejs.org
> user-agent: curl/7.86.0
> accept: */*
> accept-encoding: deflate, gzip, br
>
* TLSv1.2 (IN), TLS header, Supplemental data (23):
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* old SSL session ID is stale, removing
* TLSv1.2 (IN), TLS header, Supplemental data (23):
* Connection state changed (MAX_CONCURRENT_STREAMS == 256)!
* TLSv1.2 (OUT), TLS header, Supplemental data (23):
* TLSv1.2 (IN), TLS header, Supplemental data (23):
* TLSv1.2 (IN), TLS header, Supplemental data (23):
< HTTP/2 200
HTTP/2 200
< date: Tue, 29 Nov 2022 16:38:04 GMT
date: Tue, 29 Nov 2022 16:38:04 GMT
< content-type: text/html
content-type: text/html
< last-modified: Tue, 29 Nov 2022 12:35:20 GMT
last-modified: Tue, 29 Nov 2022 12:35:20 GMT
< cache-control: max-age=14400
cache-control: max-age=14400
< cf-cache-status: HIT
cf-cache-status: HIT
< age: 14239
age: 14239
< vary: Accept-Encoding
vary: Accept-Encoding
< strict-transport-security: max-age=31536000; includeSubDomains; preload
strict-transport-security: max-age=31536000; includeSubDomains; preload
< x-content-type-options: nosniff
x-content-type-options: nosniff
< server: cloudflare
server: cloudflare
< cf-ray: 771cc588ed8f9914-ARN
cf-ray: 771cc588ed8f9914-ARN
< content-encoding: br
content-encoding: br

<
* Connection #0 to host nodejs.org left intact

This is fixed in #2915, but still unreleased. Duplicate of #2914.

Thank you for the quick response! πŸ˜€ @ljharb