Corepack doesn't work properly inside official node docker images.
MicahZoltu opened this issue · 3 comments
FROM node:22.1.0
RUN corepack enable
WORKDIR /workspace
RUN echo 'yarnPath: .yarn/releases/yarn-4.1.1.cjs' > /workspace/.yarnrc.yml
RUN echo '{ "packageManager": "yarn@4.1.1" }' > /workspace/package.json
RUN corepack prepare yarn@4.1.1 --activate
RUN yarn install
Error:
=> [1/7] FROM docker.io/library/node:22.1.0@sha256:64c46a664eccedec63941dab4027c178a36debe08a232d4f9d7da5aca91cff3d 0.0s
=> CACHED [2/7] RUN corepack enable 0.0s
=> CACHED [3/7] WORKDIR /workspace 0.0s
=> CACHED [4/7] RUN echo 'yarnPath: .yarn/releases/yarn-4.1.1.cjs' > /workspace/.yarnrc.yml 0.0s
=> CACHED [5/7] RUN echo '{ "packageManager": "yarn@4.1.1" }' > /workspace/package.json 0.0s
=> [6/7] RUN corepack prepare yarn@4.1.1 --activate 2.0s
=> ERROR [7/7] RUN yarn install 0.8s
------
> [7/7] RUN yarn install:
0.737 Internal Error: ENOENT: no such file or directory, stat '/workspace/.yarn/releases/yarn-4.1.1.cjs'
0.737 Error: ENOENT: no such file or directory, stat '/workspace/.yarn/releases/yarn-4.1.1.cjs'
Also tested with node:22.1.0-alpine3.18
.
Of note, corepack prepare yarn@4.1.1 --activate
doesn't install yarn into /workspace/.yarn/releases/
which is where the project is looking for yarn at. If you skip the corepack prepare
step and just do yarn install
from an interactive prompt and say yes when prompted to download yarn, it gives the same error (and once again, nothing ends up in /workspace/.yarn/releases/
.
Note: I have never used corepack before and I don't personally use yarn so something in this setup may be wrong here. I came across this while trying to build someone else's project inside of docker who does use corepack and the above Dockerfile is as far as I was able to troubleshoot/narrow the issue.
That's not Corepack throwing an error, Yarn is.
Corepack doesn't look at .yarnrc.yml
, you're configuring Yarn to use /workspace/.yarn/releases/yarn-4.1.1.cjs
which doesn't exist.
Thanks! Sounds like perhaps the project in question is just setup incorrectly, which is surprising since it is used by other people (just not in Docker) but maybe they all are doing some extra steps.
My understanding was that corepack installed the selected package manager into the project. Where does it normally put the selected package manager's files?
In COREPACK_HOME
.