Skip to content

Error when ~/.cache/node/corepack is on read-only file system #420

@marvinruder

Description

@marvinruder

When running corepack enable in a Docker build stage, the directory ~/.cache/node/corepack is filled with my package manager. I would like to mount this directory and other immutable caches into a later build stage using an expression like:

FROM node:21.7.0-alpine AS build
RUN --mount=type=bind,from=yarn,source=/root/.cache,target=/root/.cache \
  yarn …
  # here I do not have to run `corepack enable` again

With Corepack 0.25.2 in node:21.7.0-alpine, this no longer works:

Internal Error: EROFS: read-only file system, open '/root/.cache/node/corepack/lastKnownGood.json'
    at async Object.open (node:internal/fs/promises:637:25)
    at async Engine.getDefaultVersion (/usr/local/lib/node_modules/corepack/dist/lib/corepack.cjs:23337:29)
    at async executePackageManagerRequest (/usr/local/lib/node_modules/corepack/dist/lib/corepack.cjs:24207:28)
    at async BinaryCommand.validateAndExecute (/usr/local/lib/node_modules/corepack/dist/lib/corepack.cjs:21173:22)
    at async _Cli.run (/usr/local/lib/node_modules/corepack/dist/lib/corepack.cjs:22148:18)
    at async Object.runMain (/usr/local/lib/node_modules/corepack/dist/lib/corepack.cjs:24279:12)

This looks like a regression of #382 where the case of ENOENT was considered, but EROFS was not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions