New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Recover from failed publish #455
Comments
@heruan Yikes! Sorry you ran into trouble. Lerna uses git tags to keep track of published versions. It looks like the tag for the version you were in the middle of publishing may have been created before the command failed. You can see the latest tag with this command:
And you can see the associated commit using the tag name:
The tag should refer to a commit on your current branch. If you haven't made any commits since the failed publish then it should be A few things to check:
It's important to know the state of your packages in the npm registry and your repo in your remote repository before proceeding. |
I just got bit by a similar issue. It would be awesome if lerna could retry a publish after failing. |
I had the same issue: I've added new package, but when I wanted to publish it, I had version 0.0.13, started update to 0.0.14 with lerna, but after this fail I see
Any thoughts how to fix it? UPD: fixed it with publishing custom version, but anyway "current" version in this case determined incorrectly |
I always get this issue when I forget to |
I use this script to double check if the packages that are managed by lerna have the latest dependencies as well as if they conflict with npm after publishing fails: https://gist.github.com/rjdestigter/e673ccfcfff921d40d26246bfbb4ca60 (Install the necessary imports at the top and replace "NAMEOFYOURORGINISATION" with your npm organisation name.) The script basically collects all package.json files. Then for each package checks if it depends on packages within my organisation and is behind in a dependency version. Then it uses |
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... what is the solution for this? how can i republish already created tags by lerna |
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): ~/d/o/puppeteer-extra git:master ❯❯❯ git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
nothing to commit, working directory clean
~/d/o/puppeteer-extra git:master ❯❯❯ git log
commit 603032ec35b16a6eb60a9940cb0801de78fef9bb
Date: Sat Aug 18 19:47:52 2018 +0200
Publish
- puppeteer-extra-plugin-anonymize-ua@2.0.8
- puppeteer-extra-plugin-block-resources@2.0.9
(...)
~/d/o/puppeteer-extra git:master ❯❯❯ git describe --abbrev=0 --tags
puppeteer-extra-plugin-devtools@2.0.9 Revert failed publish (doesn't reset tags, only the last commit): ~/d/o/puppeteer-extra git:master ❯❯❯ git reset --hard HEAD^
HEAD is now at c7537d0 Update docs Confirm and fix yarn / npm issue: ❯❯❯ yarn login
yarn login v1.7.0
info npm username: berstend
❯❯❯ npm whoami
npm ERR! code E401
❯❯❯ npm login
Username: berstend
❯❯❯ npm whoami
berstend Upgrade lerna (i was still on ~/d/o/puppeteer-extra git:master ❯❯❯ yarn add lerna --ignore-workspace-root-check --dev Modify lerna.json to use npm instead of yarn as registry client (it just wouldn't work with yarn): "npmClient": "npm",
"registry": "https://registry.npmjs.org/", ... and finally run Whew! The yarn error I was hitting (for google fu):
|
When 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? |
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 had a lerna publish error because of a wrong configured .npmrc |
What's the status with this issue? I just had a situation where I tried to |
I don't know the Lerna's code base, but it seems so trivial of a change to just delay the Anyway, at least there's the hidden I've seen in other issues suggestions to use |
Thanks for pointing out |
The way I fixed this issue is as follows:
|
Hi Folks 👋 As you may have seen in our published roadmap for Lerna v7 here: #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 🙏 |
Hi again, delighted to say that this capability is already available in the latest lerna ( Please upgrade to the latest and you should not run into republishing issues again. Many thanks! |
#!/bin/sh
# Run an npm command
npm run lerna publish
# Check the exit code of the previous command
if [ $? -ne 0 ]; then
# If the exit code is not 0, an error occurred
echo "An error occurred while running the npm command. Running error script..."
# Execute the error script
# Check if the system is macOS
if [ "$(uname)" != "Darwin" ]; then
echo "This script is only compatible with macOS."
exit 1
fi
# Check if jq is installed and available in the PATH
if ! command -v jq >/dev/null 2>&1; then
echo "jq is not installed or not in the PATH. Please install jq first."
exit 1
fi
# Define variables
JSON_FILE="./lerna.json"
KEY="version"
# Extract the value of the specified key from the JSON file and save it as a variable
VALUE=v$(cat "$JSON_FILE" | jq -r ".$KEY")
# Print the value of the variable
echo "$VALUE"
# Remove the last commit and tag in the local repo
git reset --hard HEAD^
git tag -d "$VALUE"
# Remove the last commit and tag in the remote (Github) repository
git push origin +HEAD
git push --delete origin "$VALUE"
fi |
I lost connectivity during
lerna publish
and some packages gotlerna-temp
published and other not. Now I have a dirty tree werelerna publish
fails with:How can I recover from this?
The text was updated successfully, but these errors were encountered: