pnpm: Issue with pnpmfileChecksum and frozen-lockfile

          Hey guys, I want to be clear here. We've identified that we're using 9.0.2 to both generate the lock file and we're also using 9.0.2 in the Docker image. This is still an ongoing issue.

In our local machines:

❯ sudo corepack prepare pnpm@latest --activate
Password:
Preparing pnpm@latest for immediate activation...
❯ pnpm -v
9.0.2
❯ rm -rf pnpm-lock.yaml
❯ pnpm i
Scope: all 8 workspace projects
packages/server                          |  WARN  deprecated json2csv@5.0.7
 WARN  3 deprecated subdependencies found: dommatrix@1.0.3, eivindfjeldstad-dot@0.0.1, uuid@3.3.2
Packages: +154 -150
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------
Progress: resolved 1655, reused 1539, downloaded 0, added 151, done

In our Dockerfile:

FROM node:20.12.0-slim as corepack

ARG PACKAGE
RUN corepack enable && corepack prepare pnpm@9.0.2 --activate 

The result:

❯ docker compose build server
[+] Building 22.6s (16/27)                                                                                             docker:orbstack
 => [server internal] load build definition from Dockerfile                                                                       0.0s
 => => transferring dockerfile: 1.75kB                                                                                            0.0s
 => [server internal] load metadata for docker.io/library/node:20.12.0-slim                                                       0.5s
 => [server internal] load .dockerignore                                                                                          0.0s
 => => transferring context: 405B                                                                                                 0.0s
 => [server internal] load build context                                                                                          0.4s
 => => transferring context: 28.43MB                                                                                              0.4s
 => CACHED [server corepack 1/4] FROM docker.io/library/node:20.12.0-slim@sha256:dcb9e35d8afca163a231cdfad9657d2360947f212faf0fa  0.0s
 => [server corepack 2/4] RUN corepack enable && corepack prepare pnpm@9.0.2 --activate                                           1.2s
 => [server corepack 3/4] RUN corepack prepare npm@10.3.0 --activate                                                              1.2s
 => [server corepack 4/4] WORKDIR /app                                                                                            0.0s
 => [server ssl 1/2] RUN apt-get update && apt-get install -y openssl apt-transport-https ca-certificates curl gnupg graphicsma  15.7s
 => [server ssl 2/2] RUN apt-get update && apt-get install -y python3.11-venv                                                     3.1s
 => [server dependencies 1/8] COPY [package.json, pnpm-lock.yaml, pnpm-workspace.yaml, tsconfig.json, ./]                         0.0s
 => CANCELED [server stage-4 1/6] RUN curl -sLf --retry 3 --tlsv1.2 --proto "=https" 'https://packages.doppler.com/public/cli/gp  0.7s
 => [server dependencies 2/8] COPY packages/server/package.json ./packages/server/package.json                                    0.0s
 => [server dependencies 3/8] COPY packages/prisma ./packages/prisma                                                              0.1s
 => [server dependencies 4/8] COPY packages/server/package.json ./packages/server/package.json                                    0.0s
 => ERROR [server dependencies 5/8] RUN pnpm i --frozen-lockfile --prod                                                           0.5s
------
 > [server dependencies 5/8] RUN pnpm i --frozen-lockfile --prod:
0.381 Scope: all 3 workspace projects
0.483  ERR_PNPM_LOCKFILE_CONFIG_MISMATCH  Cannot proceed with the frozen installation. The current "pnpmfileChecksum" configuration doesn't match the value found in the lockfile
0.483
0.483 Update your lockfile using "pnpm install --no-frozen-lockfile"
------
failed to solve: process "/bin/sh -c pnpm i --frozen-lockfile --prod" did not complete successfully: exit code: 1

This is also causing build failures in Render.com, which is using the latest version of pnpm. According to your release notes it should work with a v6 lockfile, but it’s not working with a v9 lockfile. We’ve never had these issues with pnpm@8 and we can’t upgrade to v9 because we can’t build our local Docker images.

Unsure if it matters, but our machines are Darwin based while our Docker images are Linux. Unsure how you’re generating the pnpmfileChecksum but if that is dependent on the architecture then it could cause this problem.

_Originally posted by @divmgl in https://github.com/pnpm/pnpm/issues/7938#issuecomment-2061788339_

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Comments: 31 (15 by maintainers)

Most upvoted comments

Cross-post from the Renovate side:

This is a major blocker for us right now as it turns out. We are NOT on self-hosted and can’t use allowScripts. Thus Renovate insists on removing pnpmfileChecksum. This is because Renovate uses --ignore-pnpmfile. Yes, pnpm changed behavior, but this is typical of package managers. With ignore-pnpmfile in .npmrc, we can’t take advantage of some critical pnpmfile behavior that we use for local development. Without it, the lockfile generated by non-renovate doesn’t agree with what Renovate generates. So it’s a bit of a conundrum on our side.

On the pnpm side, I think they should separate the lockfile generation from the actual execution of the script so that we can solve this problem granularly. On the Renovate side, I think the flags should be configurable to avoid this sort of thing.

I do understand that --ignore-pnpmfile is there to avoid running scripts on your environment.

In my case, the .pnpmfile.cjs is present in CI, but it seems that a pnpm install in CI is generating a lockfile WITHOUT the pnpmfileChecksum, thus causing a conflict with the one that was generated and committed locally WITH the pnpmfileChecksum. This is on pnpm v9.12.1.

(or add a new flag, I don’t know which is better)

I think adding a flag makes more sense here since we’re having these issues in cases where the pnpm options are not under our control.

Regardless, I believe I found a way to get our .pnpmfile.cjs file into the Render build. We have a monorepo and Render only uses a subset of our monorepo, so we’re thinking about fixing this by moving our .pnpmfile.cjs to our package (which is called packages/app) and then doing a symlink from the root of our repo to the file in our package:

❯ ln -s packages/app/.pnpmfile.cjs .pnpmfile.cjs

That will allow us to both use pnpm i locally and pnpm i in Render without having to customize the pnpm options. So hopefully it will work. We’re testing it now.

The next issue will come when we have more than one frontend package deployed on Render, as we’ll then need to duplicate .pnpmfile.cjs in every package.

Our team is hitting this issue when using .pnpmfile.cjs to remove a peerDependency and its peerDependenciesMeta info.

Locally pnpm --no-optional --frozen-lockfile --prefer-offline works. On CI it fails with:

 ERR_PNPM_LOCKFILE_CONFIG_MISMATCH  Cannot proceed with the frozen installation. The current "pnpmfileChecksum" configuration doesn't match the value found in the lockfile

Update your lockfile using "pnpm install --no-frozen-lockfile"

Not sure if this is related, but I can no longer build pnpm itself without getting this error: https://gitlab.archlinux.org/archlinux/packaging/packages/pnpm/-/blob/0fbe9964ffd909b5f6ea3a41cd471f34a20aa9db/PKGBUILD#L23

 ERROR  Cannot proceed with the frozen installation. The current "pnpmfileChecksum" configuration doesn't match the value found in the lockfile
Update your lockfile using "pnpm install --no-frozen-lockfile"

I get this error when trying to use the 9.7.1 Arch package to build 9.8, 9.9, or even rebuilding 9.7.1. I also get this error when trying to use https://github.com/pnpm/pnpm/releases/download/v9.9.0/pnpm-linuxstatic-arm64 to build 9.9.

I think that should be fine

We could add a way to remove other types of dependencies using settings. It was already requested once.

overrides cannot remove dependencies.

I think in this scenario it would be OK to ignore the missing pnpmfile.