lerna: Recover from failed publish
I lost connectivity during lerna publish and some packages got lerna-temp published and other not. Now I have a dirty tree were lerna publish fails with:
$ lerna publish
Lerna v2.0.0-beta.30
Independent Versioning Mode
Checking for updated packages...
Errored while running PublishCommand.initialize
Error: No updated packages to publish.
    at PublishCommand.initialize (/usr/local/lib/node_modules/lerna/lib/commands/PublishCommand.js:94:18)
    at PublishCommand._attempt (/usr/local/lib/node_modules/lerna/lib/Command.js:161:21)
    at PublishCommand.runCommand (/usr/local/lib/node_modules/lerna/lib/Command.js:145:12)
    at PublishCommand.run (/usr/local/lib/node_modules/lerna/lib/Command.js:69:12)
    at Object.<anonymous> (/usr/local/lib/node_modules/lerna/bin/lerna.js:58:11)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Function.Module.runMain (module.js:441:10)
How can I recover from this?
About this issue
- Original URL
 - State: closed
 - Created 8 years ago
 - Reactions: 20
 - Comments: 18 (3 by maintainers)
 
That would be my vote too. I don’t think the “Publish” commit or tag should be pushed if the NPMs don’t publish.
I just got bit by a similar issue.
lerna publishfailed because one of my scoped packages was not yet published with--access=publicso npm rejected the publish. After correcting that,lernathinks there is nothing updated to publish, but none of the npm tags have yet been updated.It would be awesome if lerna could retry a publish after failing.
I always get this issue when I forget to
npm loginbefore publishing new public packagesThe way I fixed this issue is as follows:
Uncommit from the local repo and tag.
Remove the last commit and tag in the remote (Github) pushed by Lerna.
Retry
lerna publishWhen publishing to the registry fails, is it possible to not only not push the “Publish” commit, but to revert the commit and delete the tags? Or just not take these steps until the packages have been successfully published?
I don’t know the Lerna’s code base, but it seems so trivial of a change to just delay the
git pushto the last step. It’s quite simple to revert all other Git changes manually (deleting tags and resetting to previous commit), but once tags are pushed, it can be really hard to delete them (someone else may have already fetched them and they have to manually delete them as well).Anyway, at least there’s the hidden
--no-pushoption (it’s not in the publish help, but it works), so I’m usinglerna publish --no-push && git push --tags.I’ve seen in other issues suggestions to use
from-packageto just retry without having to undo anything on Git, but, if I understand well, that only works if the issue was temporary, not if there was a bug in your code preventing the publishing to work (e.g. a mistake in somepackage.jsonthat only affects the publish command), because that requires a new commit to fix it, and therefore you normally don’t want leave the wrong tags the repository.Hi Folks 👋
As you may have seen in our published roadmap for Lerna v7 here: https://github.com/lerna/lerna/discussions/3410 recoverable publish is a priority for us in this current phase of work.
I am going to close any duplicate issues in this area and point them here. As a lerna user myself I’m excited to land this!
Many thanks 🙏
I ran into this issue as well where my lerna publish failed due to some issue with our repository but the tags were created and now i am not able to republish that since it says no updated packages to publish
lerna info Checking for prereleased packages… lerna info No updated packages to publish.
what is the solution for this? how can i republish already created tags by lerna
Hi again, delighted to say that this capability is already available in the latest lerna (
6.5.1at the time of writing) thanks to #3513Please upgrade to the latest and you should not run into republishing issues again.
Many thanks!
I had the same issue: I’ve added new package, but when I wanted to publish it,
npm publishfailed with “You should confirm your email before publishing new package” and after that I can’t publish new version.I had version 0.0.13, started update to 0.0.14 with lerna, but after this fail I see
vundefinedtag was created, but nov0.0.14. I tried to createv0.0.14tag manually,git pull --tags, but after runninglerna publishI seevundefinedagain. After that I deleted tagvundefined,git describe --abbrev=0 --tagscorrectly shows last tag, butlerna publishsays:Any thoughts how to fix it?
UPD: fixed it with publishing custom version, but anyway “current” version in this case determined incorrectly
I had a lerna publish error because of a wrong configured .npmrc In my case I had to (fix my npmrc first and then) go through all my packages and and execute manually
npm publish --ignore-scripts <packagename.tgz>(tgz files where already created by lerna publish)I ran into this as well today (a yarn token issue mentioned in #1347). To my future self 😄:
Confirm publishing state (no commits had been pushed yet):
Revert failed publish (doesn’t reset tags, only the last commit):
Confirm and fix yarn / npm issue:
Upgrade lerna (i was still on
2.11.0and3.1.1handles publishing errors better):Modify lerna.json to use npm instead of yarn as registry client (it just wouldn’t work with yarn):
… and finally run
lerna publishtwo times (one for good measure and one due to existing tags).Whew!
The yarn error I was hitting (for google fu):