lerna publish fails with code 128
learn publish task get success result but return 128 code.
Expected Behavior
Complete the publish with correct return.
Current Behavior
Step 17/27 : RUN lerna publish from-package --yes --no-git-reset --registry http://verdaccio:4873
---> Running in 3a471ffbbd92
info cli using local version of lerna
lerna notice cli v4.0.0
lerna notice FYI Unable to verify working tree, proceed at your own risk
lerna WARN Unable to determine published version, assuming "@scope/project-2" unpublished.
lerna WARN Unable to determine published version, assuming "@scope/project-1" unpublished.
Found 2 packages to publish:
- @scope/project-1=> 1.0.0
- @scope/project-2 => 1.0.0
lerna info auto-confirmed
lerna info publish Publishing packages to npm...
lerna notice Skipping all user and access validation due to third-party registry
lerna notice Make sure you're authenticated properly ¯\_(ツ)_/¯
lerna notice FYI Unable to set temporary gitHead property, it will be missing from registry metadata
lerna info lifecycle root@undefined~prepare: root@undefined
lerna WARN lifecycle root@undefined~prepare: cannot run in wd root@undefined husky install (wd=/home/app)
lerna http fetch PUT 201 http://verdaccio:4873/@scope%2fproject-1 63ms
lerna success published @scope/project-1 1.0.0
lerna notice
lerna notice package: @scope/[email protected]
lerna notice === Tarball Contents ===
...
lerna notice === Tarball Details ===
lerna notice name: @scope/project-1
lerna notice version: 1.0.0
lerna notice filename: scope-project-1-1.0.0.tgz
lerna notice package size: 2.2 kB
lerna notice unpacked size: 5.0 kB
lerna notice shasum: e53d4a877b93ded03fbf963361fcdfed26964b06
lerna notice integrity: sha512-IIwEQAoY+2Jp2[...]ckHIlblArCIOQ==
lerna notice total files: 6
lerna notice
lerna http fetch PUT 201 http://verdaccio:4873/@scope%2fproject-2 46ms
lerna success published @scope/project-2 1.0.0
lerna notice
lerna notice package: @scope/[email protected]
lerna notice === Tarball Contents ===
...
lerna notice === Tarball Details ===
lerna notice name: @scope/project-2
lerna notice version: 1.0.0
lerna notice filename: scope-projecy-2-1.0.0.tgz
lerna notice package size: 19.3 kB
lerna notice unpacked size: 161.6 kB
lerna notice shasum: 813955c93200b7b4c71a211ee00aa7db615a7d50
lerna notice integrity: sha512-WHmDH12wdLrA6[...]v0ETCW/u1GAdw==
lerna notice total files: 57
lerna notice
Successfully published:
- @scope/[email protected]
- @scope/[email protected]
lerna success published 2 packages
The command '/bin/sh -c lerna publish from-package --yes --no-git-reset --registry http://verdaccio:4873' returned a non-zero code: 128
Possible Solution
Steps to Reproduce (for bugs)
- Create a Dockerfile to publish to a local verdaccio.
- Create npm user.
- Publish
lerna.json
{
"packages": ["packages/*"],
"version": "0.0.0",
"npmClient": "yarn",
"useWorkspaces": true
}
lerna-debug.log
Step 17/27 : RUN lerna publish from-package --yes --no-git-reset --registry http://verdaccio:4873
---> Running in 3a471ffbbd92
info cli using local version of lerna
lerna notice cli v4.0.0
lerna notice FYI Unable to verify working tree, proceed at your own risk
lerna WARN Unable to determine published version, assuming "@scope/project-2" unpublished.
lerna WARN Unable to determine published version, assuming "@scope/project-1" unpublished.
Found 2 packages to publish:
- @scope/project-1=> 1.0.0
- @scope/project-2 => 1.0.0
lerna info auto-confirmed
lerna info publish Publishing packages to npm...
lerna notice Skipping all user and access validation due to third-party registry
lerna notice Make sure you're authenticated properly ¯\_(ツ)_/¯
lerna notice FYI Unable to set temporary gitHead property, it will be missing from registry metadata
lerna info lifecycle root@undefined~prepare: root@undefined
lerna WARN lifecycle root@undefined~prepare: cannot run in wd root@undefined husky install (wd=/home/app)
lerna http fetch PUT 201 http://verdaccio:4873/@scope%2fproject-1 63ms
lerna success published @scope/project-1 1.0.0
lerna notice
lerna notice package: @scope/[email protected]
lerna notice === Tarball Contents ===
...
lerna notice === Tarball Details ===
lerna notice name: @scope/project-1
lerna notice version: 1.0.0
lerna notice filename: scope-project-1-1.0.0.tgz
lerna notice package size: 2.2 kB
lerna notice unpacked size: 5.0 kB
lerna notice shasum: e53d4a877b93ded03fbf963361fcdfed26964b06
lerna notice integrity: sha512-IIwEQAoY+2Jp2[...]ckHIlblArCIOQ==
lerna notice total files: 6
lerna notice
lerna http fetch PUT 201 http://verdaccio:4873/@scope%2fproject-2 46ms
lerna success published @scope/project-2 1.0.0
lerna notice
lerna notice package: @scope/[email protected]
lerna notice === Tarball Contents ===
...
lerna notice === Tarball Details ===
lerna notice name: @scope/project-2
lerna notice version: 1.0.0
lerna notice filename: scope-projecy-2-1.0.0.tgz
lerna notice package size: 19.3 kB
lerna notice unpacked size: 161.6 kB
lerna notice shasum: 813955c93200b7b4c71a211ee00aa7db615a7d50
lerna notice integrity: sha512-WHmDH12wdLrA6[...]v0ETCW/u1GAdw==
lerna notice total files: 57
lerna notice
Successfully published:
- @scope/[email protected]
- @scope/[email protected]
lerna success published 2 packages
The command '/bin/sh -c lerna publish from-package --yes --no-git-reset --registry http://verdaccio:4873' returned a non-zero code: 128
Context
Your Environment
| Executable | Version |
|---|---|
lerna --version |
4.0.0 |
yarn --version |
1.22.5 |
node --version |
14:15 |
| OS | Version |
|---|---|
| NAME | VERSION |
Im also getting this issue, but with Github package registry (everything appears to publish correctly though)
For me this is because in https://github.com/lerna/lerna/blob/main/commands/version/lib/git-push.js#L17
return childProcess
.exec("git", ["push", "--follow-tags", "--no-verify", "--atomic", remote, branch], opts)
.catch((error) => {
git push --atomic fails with exit code 128. This error is then caught, suppressed and the push retried without --atomic.
However in child-process, the exit code has been propagated to the overall process exit code if it was non-zero:
https://github.com/lerna/lerna/blob/main/core/child-process/index.js#L137
// propagate exit code, if any
if (exitCode) {
process.exitCode = exitCode;
}
};
The if guard means the subsequent successful push does not overwrite the saved error code.
Any updates about this issue? Same error in my CI environment.
When to publish a new version? @blushingpenguin
@ssehacker not sure why you are tagging me -- this isn't my project
git rm --cached directory git add direcotry
Also seeing this error after upgrading lerna from 3.22.1 to 5.4.3 using an Azure DevOps repo. It seems to be connected to the git push of the publishing process and lack of support for git push --atomic
First, I see this output when the publish process begins:
WARN gitPush fatal: the receiving end does not support --atomic push
info gitPush --atomic failed, attempting non-atomic push
Lerna successfully publishes the packages (commit + tags are pushed to repo and package is published to registry), but the process exits with an npm error, ELIFECYCLE code 128.
lerna success published 1 package
npm ERR! code ELIFECYCLE
npm ERR! errno 128
npm ERR! [email protected] publish: `lerna publish`
npm ERR! Exit status 128
I can avoid this error by running lerna publish --no-push, and then pushing manually afterwards:
git push --follow-tags --no-verify origin master
I'm working with an NPM workspace that has the registry defined in the package.json. Not sure it the command infers the registry from the publishConfig or not, but the rest of the publish process does work.
In order to fix this issue. I just needed to add the registry to the command as well:
lerna publish from-package --registry https://npm.pkg.github.com/
Here this lerna.json, if anyone else finds this important:
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"useWorkspaces": true,
"version": "independent",
"command": {
"version": {
"allowBranch": "release",
"message": "chore(release): publish",
"conventionalCommits": true
}
}
}