An error in a build process which stops as YN0028: The lockfile would have been created by this install, which is explicitly forbidden

The problem

The build stops at the initialising phase with the following two key error messages:

4:29:40 PM: Installing npm packages using Yarn version 3.6.4
4:29:41 PM: ➤ YN0028: The lockfile would have been created by this install, which is explicitly forbidden.

The site: fluffy-pony-237262.

Build log:

4:21:37 PM: build-image version: 2821c5fd78f4042b4bb03d028b1983667d2e2d9c (focal)
4:21:37 PM: buildbot version: 9c122e4d38ef873d49667acc314f41647c44b72a
4:21:37 PM: Building without cache
4:21:37 PM: Starting to prepare the repo for build
4:21:38 PM: No cached dependencies found. Cloning fresh repo
4:21:38 PM: git clone --filter=blob:none git@gitlab.com:jari.itsellesi/okv-homepage
4:21:39 PM: Preparing Git Reference refs/heads/main
4:21:43 PM: Custom publish path detected. Proceeding with the specified path: “homepage-fi/public”
4:21:43 PM: Custom build command detected. Proceeding with the specified command: “npm run build”
4:21:44 PM: Starting to install dependencies
4:21:44 PM: Python version set to 3.8
4:21:44 PM: Attempting Ruby version 2.7.2, read from environment
4:21:44 PM: Using Ruby version 2.7.2
4:21:45 PM: Started restoring cached go cache
4:21:45 PM: Finished restoring cached go cache
4:21:45 PM: go version go1.19.13 linux/amd64
4:21:45 PM: Using PHP version 8.0
4:21:46 PM: Downloading and installing node v21.5.0…
4:21:46 PM: Downloading https://nodejs.org/dist/v21.5.0/node-v21.5.0-linux-x64.tar.xz
4:21:47 PM: Computing checksum with sha256sum
4:21:47 PM: Checksums matched!
4:21:49 PM: Now using node v21.5.0 (npm v10.2.4)
4:21:49 PM: Enabling Node.js Corepack
4:21:49 PM: Started restoring cached build plugins
4:21:49 PM: Finished restoring cached build plugins
4:21:49 PM: Started restoring cached corepack dependencies
4:21:49 PM: Finished restoring cached corepack dependencies
4:21:49 PM: Started restoring cached yarn cache
4:21:49 PM: Finished restoring cached yarn cache
4:21:50 PM: Installing Yarn version 1.22.19
4:21:50 PM: Preparing yarn@1.22.19 for immediate activation…
4:21:50 PM: No yarn workspaces detected
4:21:50 PM: Started restoring cached node modules
4:21:50 PM: Finished restoring cached node modules
4:21:50 PM: Installing npm packages using Yarn version 3.6.4
4:21:51 PM: Failed during stage “Install dependencies”: dependency_installation script returned non-zero exit code: 1
4:21:51 PM: ➤ YN0028: The lockfile would have been created by this install, which is explicitly forbidden.
4:21:51 PM: ➤ YN0000: Failed with errors in 0s 2ms
4:21:51 PM: Error during Yarn install
4:21:51 PM: Failing build: Failed to install dependencies
4:21:51 PM: Finished processing build request in 13.694s

(EDIT: fixed site name.)

The problem was that yarn.lock file was not managed in the repo build treated as a build artefact (that is it was on the .gitignore). Adding it to the repo fixed the problem.

1 Like

Thank for sharing your solution!