asdf-nodejs icon indicating copy to clipboard operation
asdf-nodejs copied to clipboard

bug: Asdf nodejs plugin inside alpine container : ~/.asdf/installs/nodejs/17.3.0/bin/node: No such file or directory

Open trompx opened this issue 3 years ago • 4 comments

Describe the Bug

I try to install asdf with nodejs plugin in an alpine docker container.

While it works in an ubuntu 18.04 docker image, it fails in alpine.

Steps to Reproduce

Start of the Dockerfile

FROM ubuntu:18.04
RUN apt-get update -q && apt-get install -y \
  curl \
  git

And

FROM alpine:latest
RUN apk --no-cache add bash git curl

End of the Dockerfile

RUN adduser --shell /bin/bash --home /ci --disabled-password ci

ENV PATH="${PATH}:/ci/.asdf/shims:/ci/.asdf/bin"
ENV NODEJS_CHECK_SIGNATURES=no

USER ci
WORKDIR /ci

RUN git clone --depth 1 https://github.com/asdf-vm/asdf.git $HOME/.asdf && \
    echo '. $HOME/.asdf/asdf.sh' >> $HOME/.bashrc && \
    echo '. $HOME/.asdf/asdf.sh' >> $HOME/.profile

RUN asdf plugin-add nodejs
RUN asdf install nodejs latest
RUN asdf global nodejs latest

# With Ubuntu 18.04, this works. With alpine, this fails with the error:
# /ci/.asdf/lib/commands/command-exec.bash: line 28: /ci/.asdf/installs/nodejs/17.3.0/bin/node: No such file or directory
# STDERR: The command '/bin/sh -c node --version' returned a non-zero code: 127
RUN node --version
RUN npm -v

Expected Behaviour

Node shoud be found like in ubuntu. I checked inside the container with a ls /ci/.asdf/installs/nodejs/17.3.0/bin and the node file exists.

Actual Behaviour

I get the error:

/ci/.asdf/lib/commands/command-exec.bash: line 28: /ci/.asdf/installs/nodejs/17.3.0/bin/node: No such file or directory STDERR: The command '/bin/sh -c node --version' returned a non-zero code: 127

Environment

OS:
Linux 0fdc9c1601ae 5.8.0-45-generic asdf-vm/asdf#51~20.04.1-Ubuntu SMP Tue Feb 23 13:46:31 UTC 2021 x86_64 Linux

SHELL:
GNU bash, version 5.1.8(1)-release (x86_64-alpine-linux-musl)
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

ASDF VERSION:
v0.9.0-87137e4

ASDF ENVIRONMENT VARIABLES:

ASDF INSTALLED PLUGINS:
nodejs                       https://github.com/asdf-vm/asdf-nodejs.git master ed34355

asdf plugins affected (if relevant)

nodejs

trompx avatar Jan 04 '22 02:01 trompx

I have moved this issue to the asdf-nodejs repo as I believe it's specific to nodejs.

ENV PATH="${PATH}:/ci/.asdf/shims:/ci/.asdf/bin"

You shouldn't need that line. And if you want to manually set the path asdf dirs should come before everything else.

Stratus3D avatar Jan 06 '22 14:01 Stratus3D

What happens if you run asdf reshim prior to trying to use node?

Stratus3D avatar Jan 06 '22 14:01 Stratus3D

node-build does not yet support musl libc: https://github.com/nodenv/node-build/issues/722

johnhamelink avatar Jan 12 '22 21:01 johnhamelink

Hello @trompx, check if after following the steps on https://github.com/asdf-vm/asdf-nodejs/issues/190#issuecomment-1034334159 you can get it working.

augustobmoura avatar Feb 10 '22 00:02 augustobmoura

This is a bit old but I'm seeing a similar behavior on alpine in my docker container. But mine looks like:

bash: /root/.asdf/installs/nodejs/19.1.0/bin/node: cannot execute: required file not found

Any progress on this? I'm not even sure how to debug this.

Nate-Wilkins avatar Nov 23 '22 04:11 Nate-Wilkins

This likely an issue that is resolved by installing libc6-compat. Add this to the alpine dockerfile:

RUN apk update && apk upgrade && apk add bash libc6-compat

vuldin avatar Jan 01 '23 04:01 vuldin

@augustobmoura do you want to close this issue? Or is there something else we can do for it?

Stratus3D avatar May 18 '23 19:05 Stratus3D

Let's close this in favor of #190, we can keep the discussion over there

augustobmoura avatar May 20 '23 17:05 augustobmoura