# Fix ERR_PNPM_OUTDATED_LOCKFILE When CI Runs pnpm install

Yes. An agent reproduces the frozen-lockfile refusal, regenerates pnpm-lock.yaml with the pnpm CI uses, and opens a PR that makes the install pass.

[Run this on Rush](https://cloud.getrush.ai/run/fix-err-pnpm-outdated-lockfile/pnpm/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent clones the repository into its own cloud sandbox and reads how it installs. In a small Express service like grubersjoe/github-contributions-api, `package.json` has no `packageManager` field, `engines.node` is `>=22`, and the `check` script runs `pnpm install --frozen-lockfile --ignore-scripts` before Prettier, `tsc`, ESLint and `vitest`. `pnpm-lock.yaml` starts with `lockfileVersion: '9.0'`, `pnpm-workspace.yaml` sets `minimumReleaseAge: 4320`, and `.github/workflows/test.yml` installs pnpm 12 through `pnpm/action-setup`, caches the store by the lockfile's hash and runs `pnpm install -r --ignore-scripts`. Dependabot is configured in `.github/dependabot.yml` to group minor and patch updates weekly with a three-day cooldown.

Then it reproduces the failure. With pnpm 12.18.0, raising `zod` from `^4.6.5` to `^4.7.0` in `package.json` without touching the lockfile and running `pnpm install --frozen-lockfile --ignore-scripts` stops with `ERR_PNPM_OUTDATED_LOCKFILE`: `Cannot install with "frozen-lockfile" because pnpm-lock.yaml is not up to date with package.json`, followed by the reason, `specifiers in the lockfile don't match specifiers in package.json`, the importer `.`, and the one mismatched dependency with both specifiers. The same command with no flag but `CI=true` set fails identically, because pnpm turns the frozen lockfile on whenever it sees a CI environment, so the workflow's plain `pnpm install -r` is a frozen install too.

The agent then works out which of the two usual causes applies. One is a hand edit: someone changed a version range in `package.json`, or resolved a merge conflict there, and did not run `pnpm install`. The other is a pnpm major that differs between the lockfile and CI, which the agent rules in or out by comparing the `lockfileVersion` the file carries with the one the installed pnpm writes; pnpm 12 still writes `9.0` here, so that is not the cause in this repository. The fix for the first cause is to run `pnpm install` once with the same pnpm major the workflow pins, which rewrites the lockfile entry, then run the `check` script to confirm the frozen install, the type check, the linter and the tests pass. Regenerating with pnpm 12 here also re-resolves a few peer-dependency variants, such as which `supports-color` the `express` entries point at, so the agent reads the whole lockfile diff and explains those lines in the pull request rather than leaving a reviewer to wonder whether they were meant.

To keep it from recurring, the agent adds a `packageManager` field naming the exact pnpm version the workflow installs, so Corepack and `pnpm/action-setup` agree with the lockfile, and notes in the pull request that every pull request which edits `package.json` must carry the matching `pnpm-lock.yaml` change. It does not loosen the install: removing `--frozen-lockfile` or adding `--no-frozen-lockfile` to CI would let a drifted lockfile pass silently, which is the condition the error exists to catch.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "CI fails on pnpm install with ERR_PNPM_OUTDATED_LOCKFILE. Read package.json, pnpm-lock.yaml, pnpm-workspace.yaml and the GitHub Actions workflow first, and note which pnpm version the workflow installs and the lockfileVersion the lockfile carries. Reproduce the failure with the same pnpm major and `pnpm install --frozen-lockfile`, and quote the mismatched specifiers it reports. Find out whether the cause is an edit to package.json without a lockfile update or a pnpm major mismatch, then regenerate pnpm-lock.yaml with the pnpm version CI uses, run the project's check or test script, and open a pull request with the lockfile change and a packageManager field pinning that pnpm version. Do not remove --frozen-lockfile from CI and do not change any dependency version beyond what package.json already asks for.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

What comes back is a pull request touching `pnpm-lock.yaml` and `package.json`: the lockfile entry for the edited dependency brought in line with its specifier, with any peer-resolution lines pnpm rewrote at the same time listed and explained, and a `packageManager` field naming the pnpm version the workflow installs. The description quotes the `ERR_PNPM_OUTDATED_LOCKFILE` output with the mismatched specifiers from the failing run, the `lockfileVersion` before and after, and the output of the `check` script after the fix: the frozen install, Prettier, `tsc`, ESLint and `vitest` in order.

A reviewer checks that every line of the lockfile diff is either the edited dependency's resolution or a peer-resolution change the description accounts for, not a wholesale re-resolution of every package, that the `packageManager` version matches `pnpm/action-setup` in the workflow, and that no CI flag was weakened. The run's record holds the failing and passing installs with their full output, so the reviewer can read the exact refusal rather than take the summary on trust.

## Run it on every failed install in CI

Add an automation to the Project with this prompt and a `github` trigger on `workflow_run.failure`, with `branch_patterns` set to the branches CI protects, so a contributor's broken fork does not start a run. The trigger appends the failed run's event after the prompt, and the agent reads the workflow and job from it; a failure that is not the lockfile error ends with a one-line answer naming what failed instead. `max_runs_per_hour` caps what a flapping pipeline can start.

From your own server instead, a handler for GitHub's `workflow_run` webhook with `conclusion: failure` sends this body to `POST /o/{org}/sessions` with an API key, the repository in `resources`, and a `request_id` that is a UUID v5 of the run id, so a redelivered event returns the run already started rather than opening a second pull request. A `webhook_url` on the key receives `run.completed` with `data.session_url` when the pull request is up.

## Why run it on Rush?

This error only exists under the conditions CI creates: a clean checkout, a frozen lockfile and a pnpm version pinned in a workflow file, none of which a laptop with a warm store and a different pnpm reproduces. The agent's sandbox is that clean checkout. It installs the pnpm major the workflow names, runs the frozen install and sees the same refusal CI saw, and every command it ran stays in the run's record with its output.

The fix is small but the proof is not: a regenerated lockfile has to be checked by the install it was regenerated for, and then the type check, lint and tests that the `check` script chains after it. The agent runs the whole chain in the sandbox and quotes it in the pull request, so the reviewer reads the install that passed rather than guessing whether a lockfile diff of a few lines is complete.

## Frequently asked questions

### Why does CI fail when pnpm install works on my machine?

pnpm sets `--frozen-lockfile` automatically when the `CI` environment variable is set, so the same `pnpm install` that quietly rewrites the lockfile on a laptop refuses in a workflow. The error lists the mismatched specifiers; the fix is the lockfile change, not the flag.

### Should the pull request just remove --frozen-lockfile?

No. The flag is what guarantees that CI installs exactly what the lockfile records. Removing it, or adding `--no-frozen-lockfile`, lets a drifted lockfile install something nobody reviewed. The prompt tells the agent to leave the flag alone.

### What if the cause is a pnpm version mismatch rather than a hand edit?

The agent compares the `lockfileVersion` in the file with what the installed pnpm writes. When they differ, it regenerates the lockfile with the pnpm major CI pins and adds `packageManager` so Corepack and `pnpm/action-setup` use that version everywhere. In this repository pnpm 12 writes the same `9.0` the file already carries, so the cause is the manifest edit.

### Will the agent bump dependencies while it is in there?

No. The prompt limits it to what `package.json` already asks for, so the lockfile diff covers the edited dependency and its resolution only. Dependabot's grouped weekly update, configured in this repository, is the place for version bumps.

## More pnpm jobs

- [Add GitHub Actions CI to a pnpm Project](https://getrush.ai/run/add-github-actions-ci/pnpm/)

## More jobs like this: Fix a bug from an alert

- [Fix "ESLint couldn't find an eslint.config.* file" after upgrading to ESLint 9](https://getrush.ai/run/fix-eslint-couldnt-find-eslint-config-file/eslint/)
- [Fix "TrainingArguments.__init__() got an unexpected keyword argument 'evaluation_strategy'"](https://getrush.ai/run/fix-evaluation-strategy-unexpected-keyword-argument/transformers/)
- [Fix "expected exactly 5 fields, found 6" After Upgrading robfig/cron to v3](https://getrush.ai/run/fix-expected-exactly-5-fields-found-6/robfig-cron/)
- [Fix "error: externally-managed-environment" in a Docker Build](https://getrush.ai/run/fix-externally-managed-environment/docker/)
- [Fix the Manifest Behind a Failed Argo CD Sync](https://getrush.ai/run/fix-failed-syncs/argo-cd/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
