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

Ruby image nvm cannot install node 20 #1136

Open
yart opened this issue Jul 30, 2024 · 1 comment
Open

Ruby image nvm cannot install node 20 #1136

yart opened this issue Jul 30, 2024 · 1 comment
Assignees

Comments

@yart
Copy link

yart commented Jul 30, 2024

Hello!

I'm using the following Dockerfile:

ARG RUBY_VERSION=3.3
ARG DISTRO_NAME=bullseye
FROM mcr.microsoft.com/devcontainers/ruby:1-$RUBY_VERSION-$DISTRO_NAME

ARG NODE_VERSION="20"
RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"
# . . .

And when I'm building the image, it crashes with

RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && nvm install 20 2>&1":
0.987 Version '20' not found - try `nvm ls-remote` to browse available versions.
------
failed to solve: process "/bin/sh -c su vscode -c \"source /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1\"" did not complete successfully: exit code: 3

In the same time, when I'm installing the same node's version locally, not from the Docker, it's done successfully.

Could anybody help me, please?

@samruddhikhandale
Copy link
Member

The issue you're encountering is likely due to the nvm environment not being fully initialized when running the su vscode -c command. Here's an updated version of your Dockerfile:

ARG RUBY_VERSION=3.3
ARG DISTRO_NAME=bullseye
FROM mcr.microsoft.com/devcontainers/ruby:1-$RUBY_VERSION-$DISTRO_NAME

ARG NODE_VERSION="20"

# Ensure nvm is properly sourced and initialized
RUN su vscode -c "export NVM_DIR="/usr/local/share/nvm" && \
    . /usr/local/share/nvm/nvm.sh && \
    nvm install ${NODE_VERSION} && \
    nvm use ${NODE_VERSION} && \
    nvm alias default ${NODE_VERSION}"

@yart Can you check if this works?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants