lerna icon indicating copy to clipboard operation
lerna copied to clipboard

lerna publish fails with code 128

Open iamchathu opened this issue 4 years ago • 7 comments

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)

  1. Create a Dockerfile to publish to a local verdaccio.
  2. Create npm user.
  3. 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

iamchathu avatar Aug 20 '21 12:08 iamchathu

Im also getting this issue, but with Github package registry (everything appears to publish correctly though)

dylanvorster avatar Aug 23 '21 09:08 dylanvorster

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.

blushingpenguin avatar Oct 07 '21 17:10 blushingpenguin

Any updates about this issue? Same error in my CI environment.

lucassarcanjo avatar Feb 03 '22 20:02 lucassarcanjo

When to publish a new version? @blushingpenguin

ssehacker avatar Feb 20 '22 12:02 ssehacker

@ssehacker not sure why you are tagging me -- this isn't my project

blushingpenguin avatar Feb 20 '22 21:02 blushingpenguin

git rm --cached directory git add direcotry

qianwaiwai123 avatar May 12 '22 03:05 qianwaiwai123

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

brendanmckeown avatar Aug 30 '22 13:08 brendanmckeown

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
        }
    }
}

roydukkey avatar Jan 27 '23 16:01 roydukkey