Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getting YN0028 The lockfile would have been modified by this install, which is explicitly forbidden. using yarn berry and heroku

I'm using yarn berry and heroku and consistently getting the error:

       ➤ YN0028: │ The lockfile would have been modified by this install, which is explicitly forbidden.

Which suggests that my lockfile does not contain all my listed dependencies. In the yarn docs it says this is easily solved by running yarn install and pushing new lockfile to git. However I've tried this, tried with fresh node_modules, etc with no luck.

Has anyone else experienced this issue using yarn berry + heroku?

My repo is a monorepo using workspaces.

like image 438
Tevon Strand-Brown Avatar asked Apr 12 '21 16:04

Tevon Strand-Brown


People also ask

How do you change yarn lockfile?

Your yarn. lock file is auto-generated and should be handled entirely by Yarn. As you add/upgrade/remove dependencies with the Yarn CLI, it will automatically update your yarn. lock file.

Does yarn install Update lockfile?

If you are running yarn add in your ci, such as for a ci only dependency, it will update the lock file and do an install for all dependencies.

What is yarn lockfile?

Whenever you run yarn (which is the equivalent of running yarn install ) upon a fresh install, a yarn. lock file is generated. It lists the versions of dependencies that are used at the time of the installation process. That means it looks into your package.

How do I change my yarn version?

First off, if you already have a version installed, unlink it from brew running the brew unlink yarn command in your terminal. Next, in a web browser, find the Pull Request that has been merged which contained the formula (version) of Yarn that you want to install.

Why is my LockFile not showing up in yarn?

Show activity on this post. ➤ YN0028: │ The lockfile would have been modified by this install, which is explicitly forbidden. Which suggests that my lockfile does not contain all my listed dependencies. In the yarn docs it says this is easily solved by running yarn install and pushing new lockfile to git.

Why--fronzen-LockFile option is used in yarn install?

it's say that you need to run just yarn install. --fronzen-lockfile option is tell you need to update your lock.file which will be much dependency of package in your package.json.

Why am I getting yn0021-workspace_not_found error in yarn?

This error will be generated when Yarn detects that your project references a package that isn't listed within the lockfile (usually because you modified a dependencies field without running yarn install, or because you added a new workspace). Running yarn install will almost certainly fix this particular error. YN0021 - WORKSPACE_NOT_FOUND

Why does my LockFile not contain all of my dependencies?

Bookmark this question. Show activity on this post. ➤ YN0028: │ The lockfile would have been modified by this install, which is explicitly forbidden. Which suggests that my lockfile does not contain all my listed dependencies. In the yarn docs it says this is easily solved by running yarn install and pushing new lockfile to git.


2 Answers

I was able to workaround by setting the env-var YARN_ENABLE_IMMUTABLE_INSTALLS to false, as suggested here.

This is likely a bug in Yarn Berry. I've reported it here: https://github.com/yarnpkg/berry/issues/2948


UPD: I have created a fresh local clone of the repo from GitHub, ran yarn install in it, and it did produce changes in yarn.lock. Committing those changes resolved the CI issue, so disabling YARN_ENABLE_IMMUTABLE_INSTALLS is no longer necessary for me.

The original local repo showed a clean git status, so I still believe it is a bug.

UPD 2: My problem was that one of the Yarn worspaces was checked into git as a git submodule (I have probably created it with a nested .git/ folder and then deleted it). As a result, the workspace content, including a child package.json was not committed into the repo, it only existed in my local repo and not on the remote and CI.

After removing the git submodule and checking the workspace into the repo properly, the YN0028 error stopped happening.

like image 188
Andrey Mikhaylov - lolmaus Avatar answered Oct 24 '22 06:10

Andrey Mikhaylov - lolmaus


If your ENV doesn't contain any CI variables:

Then it could be your yarn config:

Run yarn config get enableImmutableInstalls and see if it's enabled. (you can also check why it is enabled by running yarn config --why and looking for enableImmutableInstalls).

If it is true, then run yarn config set -H enableImmutableInstalls false to set the setting's value globally (or without the -H argument to set it only in your current project)

like image 21
realwoopee Avatar answered Oct 24 '22 06:10

realwoopee