nvm icon indicating copy to clipboard operation
nvm copied to clipboard

PATH wrong (node not found) when running container-image with non-interactive shell like in Gitlab CICD-Jobs

Open zenhighzer opened this issue 10 months ago • 5 comments

Hi,

we followed your guide with a slightly modification:

https://github.com/nvm-sh/nvm?tab=readme-ov-file#installing-in-docker:

FROM ubuntu:latest
ARG NODE_VERSION=20

RUN apt update && apt install -y curl

# Use bash for the shell
SHELL ["/bin/bash", "-o", "pipefail", "-c"]

# Create a script file sourced by both interactive and non-interactive bash shells
ENV BASH_ENV=/root/.bash_env
RUN touch "${BASH_ENV}"
RUN echo '. "${BASH_ENV}"' >> ~/.bashrc

# Download and install nvm
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | PROFILE="${BASH_ENV}" bash
RUN echo node > .nvmrc
RUN nvm install $NODE_VERSION && npm install --global yarn

But running the container like 'docker run --rm -it testnvm yarn -v' throws some error:

docker: Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: exec: "yarn": executable file not found in $PATH: unknown

If we start Container interactively the PATH is OK;

docker run --rm -it testnvm:latest bash
root@7a71be1a2bec:/# yarn -v
1.22.22
root@7a71be1a2bec:/# 

So we asked gpt for help. after several tries this Dockerfile seems to be working fine with interactive and non-interactive containers:

FROM ubuntu
ARG NODE_VERSION=20

# install curl 
RUN apt update && apt install curl -y 

# install nvm
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash

# set env
ENV NVM_DIR=/root/.nvm

# install nodejs and yarn
RUN bash -c "source $NVM_DIR/nvm.sh && \
    nvm install $NODE_VERSION && \
    nvm alias default $NODE_VERSION && \
    nvm use default && \
    npm install -g yarn"

# test node and yarn installation
RUN bash -c "source $NVM_DIR/nvm.sh && node -v && yarn -v"

# set ENTRYPOINT for reloading nvm, node-env, etc. everytime
ENTRYPOINT ["bash", "-c", "source $NVM_DIR/nvm.sh && exec \"$@\"", "--"]

# set cmd to bash 
CMD ["/bin/bash"]

So I wonder if you want to update your example for a more robust nodejs-container.

Best Regards

zenhighzer avatar Feb 20 '25 14:02 zenhighzer

If you omit the yarn parts, a PR to make that change would be great! that way it can get proper review.

ljharb avatar Feb 20 '25 16:02 ljharb

Hi,

I think i dont have permissions to create PR. I am not very familiar with github tbh. I updated the README / added a further docker-section.

Maybe you could have a look and create a PR?

README.md

zenhighzer avatar Feb 21 '25 09:02 zenhighzer

Everyone has permissions to make a PR :-) I’ll take a look, i can probably apply your patch.

ljharb avatar Feb 21 '25 15:02 ljharb

damn, next time i will try to create a PR :-) Thank you very much! :-)

zenhighzer avatar Feb 21 '25 15:02 zenhighzer

export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" --no-use # This loads nvm, without auto-using the default version export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" --no-use # This loads nvm, without auto-using the default version This XML file does not appear to have any style information associated with it. The document tree is shown below.

The Privacy Sandbox The Privacy Sandbox https://privacysandbox.com/ Tue, 23 Apr 2024 00:00:00 +0000 Next steps for Privacy Sandbox and tracking protections in Chrome https://privacysandbox.com/news/privacy-sandbox-next-steps Anthony Chavez VP, Privacy Sandbox In this April 2025 announcement, the Privacy Sandbox team shares next steps for Privacy Sandbox and tracking protections in Chrome. Tue, 22 Apr 2024 00:00:00 +0000 https://privacysandbox.com/news/privacy-sandbox-next-steps Announcements Unlocking effective measurement with Privacy Sandbox https://privacysandbox.com/news/effective-measurement Jolyn Yao Product Manager, Measurement Lead at Privacy Sandbox This blog post shares how the Privacy Sandbox for web empowers ad tech companies to measure advertising effectiveness while safeguarding user privacy. Tue, 12 Nov 2024 00:00:00 +0000 https://privacysandbox.com/news/effective-measurement Privacy Sandbox for the Web Announcements Your feedback in action: Upcoming Privacy Sandbox developments https://privacysandbox.com/news/upcoming-privacy-sandbox-developments Amit Varia Director of Product Management, Privacy Sandbox The first half of 2024 was filled with progress and learnings, as ad tech companies engaged in testing the core Privacy Sandbox technologies. The feedback from this testing highlighted areas for potential enhancements and continued investment from Privacy Sandbox. We're excited to share several proposals to incorporate recent feedback into the Protected Audience API. Wed, 18 Sep 2024 00:00:00 +0000 https://privacysandbox.com/news/upcoming-privacy-sandbox-developments Privacy Sandbox for the Web Announcements A new path for Privacy Sandbox on the web https://privacysandbox.com/news/privacy-sandbox-update Anthony Chavez VP, Privacy Sandbox We developed the Privacy Sandbox with the goal of finding innovative solutions that meaningfully improve online privacy while preserving an ad-supported internet that supports a vibrant ecosystem of publishers, connects businesses with customers, and offers all of us free access to a wide range of content. Mon, 22 Jul 2024 00:00:00 +0000 https://privacysandbox.com/news/privacy-sandbox-update Privacy Sandbox for the Web Announcements Learnings from Privacy Sandbox Testing https://privacysandbox.com/news/learnings-from-privacy-sandbox-testing Alex Cone Senior Product Manager, Privacy Sandbox An illustration of a testing equipment and a checklist In this post, we’ll share some key learnings and insights from the testing process. Tue, 16 Jul 2024 00:00:00 +0000 https://privacysandbox.com/news/learnings-from-privacy-sandbox-testing Privacy Sandbox for the Web Perspectives Update on the plan for phase-out of third-party cookies on Chrome https://privacysandbox.com/news/update-on-the-plan-for-phase-out-of-third-party-cookies-on-chrome Abstract image of a digital identity surrounded by web technologies that protect online privacy. We are providing an update on the plan for third-party cookie deprecation on Chrome. Tue, 23 Apr 2024 00:00:00 +0000 https://privacysandbox.com/news/update-on-the-plan-for-phase-out-of-third-party-cookies-on-chrome Privacy Sandbox for the Web Announcements Protected Audience API: Our new name for FLEDGE https://privacysandbox.com/news/protected-audience-api-our-new-name-for-fledge A user icon embeded inside a shield with the globe behind it and a rack below FLEDGE API is now named Protected Audience API. As we update resources and documentation to reflect the new name, we hope you will help with this transition by using the new name in your public materials and conversations. Mon, 17 Apr 2023 00:00:00 +0000 https://privacysandbox.com/news/protected-audience-api-our-new-name-for-fledge Announcements Privacy Sandbox for the Web Privacy Sandbox for Android Tristram Southey Product Manager, Privacy Sandbox Working Together to Build a More Private Internet https://privacysandbox.com/news/working-together-to-build-a-more-private-internet An illustration of a globe surrounded by different computer icons. The team shares four core tenets that guide the Privacy Sandbox efforts – an open letter to everyone who wants to help build a more private internet. Thu, 06 Apr 2023 00:00:00 +0000 https://privacysandbox.com/news/working-together-to-build-a-more-private-internet Perspectives Privacy Sandbox for the Web Privacy Sandbox for Android Victor Wong Senior Director of Product Management, Privacy Sandbox Maximize ad relevance without third-party cookies https://privacysandbox.com/news/maximize-ad-relevance-after-third-party-cookies A clipboard showing an advertising campaign report, a line graph chart, a calculator and coffee mug 2023 will be a critical year to prepare for a world without third-party cookies. Let’s take a closer look at how the advertising ecosystem might think about ad relevance in a cookieless future. Wed, 14 Dec 2022 00:00:00 +0000 https://privacysandbox.com/news/maximize-ad-relevance-after-third-party-cookies Perspectives Privacy Sandbox for the Web Joey Trotz Director of Product Management, Privacy Sandbox Digiday survey: Why publishers are ready to end the high cost of third-party cookies and data leakage https://privacysandbox.com/news/digiday-survey-data-leakage A broken pipeline representing data leakage While publishers have been preparing for the deprecation of third-party cookies for years, many continue to rely on them, even as they test alternatives, experiment with their own first-party data offerings and see continued data leakage. And that could be costing them revenue in the near term. Tue, 14 Nov 2023 00:00:00 +0000 https://privacysandbox.com/news/digiday-survey-data-leakage Perspectives Privacy Sandbox for the Web Joey Trotz Director of Product Management, Privacy Sandbox The next stages of Privacy Sandbox: General availability and supporting scaled testing https://privacysandbox.com/news/the-next-stages-of-privacy-sandbox-general-availability A globe that represents the open web surrounded by internet services icons. We’re sharing an update on the next stage of the Privacy Sandbox for the web, as we work towards deprecating third-party cookies in Chrome in the second half of 2024. Thu, 18 May 2023 00:00:00 +0000 https://privacysandbox.com/news/the-next-stages-of-privacy-sandbox-general-availability Announcements Privacy Sandbox for the Web Anthony Chavez VP, Privacy Sandbox Privacy Sandbox for the Web reaches general availability https://privacysandbox.com/news/privacy-sandbox-for-the-web-reaches-general-availability A grid containing a video player, two browser windows, and a shopping ad, with illustrations of a lock, magnifying glass, safe, cursor and location marker. Today, we mark a major milestone for the Privacy Sandbox for the Web, reaching "general availability" on Chrome for the relevance and measurement APIs. This milestone is a significant step on the path towards a fundamentally more private web. Thu, 07 Sep 2023 00:00:00 +0000 https://privacysandbox.com/news/privacy-sandbox-for-the-web-reaches-general-availability Announcements Privacy Sandbox for the Web Anthony Chavez VP, Privacy Sandbox How Privacy Sandbox raises the bar for ads privacy https://privacysandbox.com/news/how-privacy-sandbox-raises-the-bar-for-ads-privacy An image of web ads and a web browser with a lock in the center that represents privacy technology enhancements. The Privacy Sandbox’s privacy-preserving APIs shield the identity of the user and restrict the amount of available data, while enabling key advertising use cases. Here’s how. Tue, 15 Aug 2023 00:00:00 +0000 https://privacysandbox.com/news/how-privacy-sandbox-raises-the-bar-for-ads-privacy Perspectives Privacy Sandbox for the Web Privacy Sandbox for Android Victor Wong Senior Director of Product Management, Privacy Sandbox AdExchanger study: Cookies’ low match rates cost Ad Tech millions https://privacysandbox.com/news/adexchanger-study-cookies-low-match-rates A cookie followed by a line graph showing a downward-trending arrow and horizontal bars Recently we published a new study with AdExchanger, examining the impact of cookie matching on digital advertising – and how ad tech use legacy third-party cookies to audience match could lose millions of dollars. Wed, 12 Apr 2023 00:00:00 +0000 https://privacysandbox.com/news/adexchanger-study-cookies-low-match-rates Perspectives Privacy Sandbox for the Web Joey Trotz Director of Product Management, Privacy Sandbox Ready for Builders https://privacysandbox.com/news/ready-for-builders An illustration of a toolbox with a shield on the front Together with the industry, we’ve spent the last four years developing new building blocks for a better internet—one that keeps people’s activity private and supports free experiences for everyone. Wed, 10 Jan 2024 00:00:00 +0000 https://privacysandbox.com/news/ready-for-builders Perspectives Privacy Sandbox for the Web Victor Wong Senior Director of Product Management, Privacy Sandbox try { const cred = await navigator.credentials.get({ identity: { providers: [ { configURL: 'https://idp.example/manifest.json', clientId: '1234', }, ], } }); } catch (e) { const code = e.code; const url = e.url; } let { token } = await navigator.credentials.get({ identity: { providers: [{ // RP requests the IdP to share only username and profile picture fields: [ 'username', 'picture'], clientId: '1234', configURL: 'https://idp.example/fedcm.json', }, } }); if (rpRequestsPermissions) { // Response with a URL if the RP requests additional permissions return res.json({ continue_on: '/example-redirect', }); } let {token} = await navigator.credentials.get({ identity: { providers: [{ clientId: '1234', configURL: 'https://idp.example/fedcm.json', // Key/value pairs that need to be passed from the // RP to the IdP but that don't really play any role with // the browser. params: { IDP_SPECIFIC_PARAM: '1', foo: 'BAR' } }, } }); // The assertion endpoint is drawn from the config file POST /fedcm_assertion_endpoint HTTP/1.1 Host: idp.example Origin: https://rp.example/ Content-Type: application/x-www-form-urlencoded Cookie: 0x23223 Sec-Fetch-Dest: webidentity

// params are translated into urlencoded version of {"IDP_SPECIFIC_PARAM":"1","foo":"bar"} account_id=123&client_id=client1234&params=%22%7B%5C%22IDP_SPECIFIC_PARAM%5C%22%3A1%2C%5C%22foo%5C%22%3A%5C%22BAR%5C%22%7D%22. https://www.facebook.com/share/19T1QTRfTo/ POST /id_assertion_endpoint HTTP/1.1 Host: idp.example Origin: https://rp.example/ Content-Type: application/x-www-form-urlencoded Cookie: 0x23223 Sec-Fetch-Dest: webidentity

// The RP only requested to share email and picture. The browser will send disclosure_text_shown=false, as the 'name' field value is missing account_id=123&client_id=client1234&disclosure_text_shown=false&fields=email,picture&disclosure_shown_for=email,picture export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" --no-use # This loads nvm, without auto-using the default version POST /id_assertion_endpoint HTTP/1.1 Host: idp.example Origin: https://rp.example/ Content-Type: application/x-www-form-urlencoded Cookie: 0x23223 Sec-Fetch-Dest: webidentity

account_id=123&client_id=client1234&nonce=234234&disclosure_text_shown=false

alladdyoumax9-svg avatar Oct 17 '25 04:10 alladdyoumax9-svg