Repository navigation
Description
Hi,
I would like to propose a new option for lerna publish command, which would allow us to run lerna publish with uncommitted changes to the packages.
We need this behaviour for our benchmark test, where we publish all monorepo packages to temporary private registry, then install all these published packages to our skeleton web application. Then we build and run this web application and run simple performance tests to check, that we did not cause some critical performance issues. We run this test in CI and don't want to push, or create any commits.
Pseudo Script
# Example Repository Structure
# packages/package-a
# packages/package-b
# packages/skeleton (private)
# package.json
# Benchmark Test Script
npm install
npx lerna version prerelease --no-push --no-commit-hooks --no-git-tag-version --allow-branch '*'
npx lerna publish from-package --registry "$PRIVATE_REGISTRY" --no-push --no-git-reset # + some option to ignore uncommitted changes error
# Prepare Skeleton Website
cd $WEB_APPLICATION_PATH
npm install --registry "$PRIVATE_REGISTRY"
npm run build
npm start &
# Run Test Against Our Website
autocannon localhost:3001I found a solution to use git update-index --assume-unchanged ., that we could use in CI, but it seems a little bit dangerous and ugly and if somebody tries to run the script locally, it can have some horrible consequences.
I also tried to simply run lerna bootstrap to link all the packages together, but I ran into another issue with our gulp tasks package, which is used by skeleton web app. Since all the linked dependencies are just symlinks and can use only its own dependencies, it makes a problem when a gulp task requires some project file, which requires some project dependency, which is not a dependency of the gulp task package (I hope its understandable :D ). This could be solved by installing all the required packages as dev dependency also to the gulp task package, but it seems rather ugly solution. Also, it is more reliable test, if I try to install actually published packages, since this would also test correctly set dev/production dependencies.
I could not think of any other solution for our use case, but to create custom script to publish all the packages. But it seems unnecessarily complicated solution, because I would expect, that there should be some option for the lerna publish command, which would allow us to ignore uncommitted changes to the project.
Proposal
lerna publish --skip-check-working-treeThe option --skip-check-working-tree would skip the check-working-tree and the command would not fail, when there are some uncommitted changes in the project, when trying to publish the packages.
Another solution would be to attach this behaviour to --no-git-reset, but I am not sure, if I understand this option correctly.
Related Issues
Thank you for your attention and keep up the great work!
Filip
Activity
diminutivesloop commentedon May 29, 2020
This would also be useful for our project where we want to enforce usage of an internal npm registry for package installs via
.npmrcbut we can't commit.npmrcbecausenpm loginmodifies it right before we runlerna publish. Alternativelylerna publishcould support an--ignoreoption.seantcanavan commentedon Oct 16, 2020
Would love to see this feature as well
arlukin commentedon Nov 21, 2020
I had a similar problem in my cicd process. I do this.
And had to add
.npmrcto my.gitignore.diminutivesloop commentedon Feb 10, 2021
Also this appears to be a security issue as being unable to check-in
.npmrcopens the door for a dependency confusion attack at least on dev machines that runnpm installinstead ofnpm ci.anlesk commentedon Feb 11, 2021
Yes, missing that as well!
justrhysism commentedon Jul 27, 2021
Azure DevOps Pipelines modifies the
.npmrcwhen authenticating, resulting in this issue.I've had to work around it by ignoring the
.npmrcfile (with it already checked in) but that is far from ideal.baracudadance commentedon Nov 24, 2021
IndiraSDev commentedon Feb 26, 2023
Hello All! Can anyone please let me know if there's any update on this? I too see the same error, which says
"lerna verb git-describe undefined => "v2.0.5-g*-dirty"
lerna sill git-describe parsed => {"lastTagName":"v2.0.5","lastVersion":"v2.0.5","refCount":"11","sha":"*","isDirty":true}
lerna sill collect-uncommitted git status --porcelain (async)
lerna ERR! EUNCOMMIT Working tree has uncommitted changes, please commit or remove the following changes before continuing:"
I am not sure how to proceed from here. As far as I checked, the working tree says, it is clean.
iamdeveloperidevelop commentedon Mar 5, 2023
+1.
Creating fake commit is just awful
donmccurdy commentedon Sep 25, 2024
I'd be grateful for options (like
--skip-check-working-tree) here too. Having.yarnrc.ymlseems required for Yarn v4 and other reasons. Changes to.yarnrc.ymlare required to publish in CI, to set an NPM access token. The token cannot be passed directly tolerna publishbecause #2404 has been closed. The token cannot be committed to.yarnrc.ymlahead of time, for security. And finally, we can't do an extra commit in CI to apply unsaved changes to.yarnrc.yml, because we're relying onlerna publish from-gitand need the last commit to be the release. So, it's unclear how to runlerna publishin a CI environment.r-marmitt commentedon Jan 10, 2025
I faced the same problem. The solution I found was tell git to ignore the .npmrc file
git update-index --skip-worktree -- .npmrcPersi commentedon Jun 23, 2026
Caution: The proposed workaround caused build issues in our Gitlab CI pipelines, because per default Gitlab is using git fetch instead of git clone to load a git repository into the current runner. So in our case, after one release job succeeded with this proposal, all following pipelines failed on
npm cibecause we changed the registry field in .npmrc to our internal publish registry, which does not provide internet npm artifacts.This issue was tricky to find, because we use multiple build runners, so just runners which already executed our release job contained an invalid .npmrc, all others did not. In consequence, npm ci worked on some runners, while it continued to fail on others.