Solved: Github Actions’ pnpm-lock.yaml is absent error

2024.05.08

TL;DR

Check the version of your package manager which is being used in Github Actions and match it with the version present on the local system.

Introduction

Recently I faced an unusual error in Github Actions due to which the execution of Github Actions kept resulting in an error.

In the workflow file, there is a command which installed all the packages needed for the execution of the code. The command is

pnpm install --frozen-lockfile

Seems quite an easy command right? If the lockfile is present, pnpm proceeeds with the installation of all the packages with their respective versions. But Github Actions kept resulted in an error. Hoping that maybe something went wrong during the first run I chose to run the job again, but the workflow run kept ending with the same fate.

I was puzzled, I decided to run the command on my local system, and the command worked perfectly, without any errors. But nothing could explain the failure of Github Actions.

I even asked ChatGPT and it suggested that I should consider:

  1. Checking if lockfile exists
  2. Check workflow file to see pnpm is being configured correctly
  3. Removing --frozen-lockfile option
  4. Reviewing permissions of Github Actions

None of these were the answers I was looking for since the lockfile was already present and Github Actions were resulting in a succesful state in checks which were being run by other developers.

Solution

I decided on following ChatGPT's advice and started checking my workflow file, which is when I came across the command which configured pnpm. The version of pnpm which was being used in Github Actions was v8, whereas the version installed on my system was v9.

I changed the version of the local installation of pnpm and re-run the pnpm i <package-name> command. Re-run Github Actions and voilà the run was successful !

Additional Information

Whenever we install a command line utitlity using brew, it automatically installs the latest version, this iss the reason why I had an installation of v9 of pnpm. I followed the steps mentioned on pnpm's website to finally install the version which was being used in Github Actions.