question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

lerna run prints "success" next to failed packages

See original GitHub issue

Let’s assume I want to run all unit tests from all packages in my monorepo. So I’d call lerna run --no-bail test. I’d specify --no-bail because I don’t want to abort on the first error. I want to see which packages succeed and which fail. When Lerna is done, it prints a table that looks like this:

lerna success run Ran npm script ‘test’ in 5 packages in 0.3s: lerna success - package01 lerna success - package02 lerna success - package03 lerna success - package04 lerna success - package05

The problem is that Lerna prints “success” next to each package, even if the script for that package actually failed.

Expected Behavior

I’d expect “success” to be printed only if the error code of the packages’s script was zero. Otherwise, I’d expect “failure” or something similar to be printed next to the failed package.

Current Behavior

Currently, Lerna prints “success” next to every single package, even if its script failed and returned a non-zero exit code.

Steps to Reproduce (for bugs)

  1. Set up a monorepo with multiple packages.
  2. Create a script “test” in each monorepo. Make some scripts succeed (by calling “true” on Unix), make others fail (by calling “false” on Unix).
  3. Run lerna run --no-bail test
lerna.json

{
  "packages": ["packages/*"],
  "version": "1.0.0",
  "npmClient": "yarn",
  "useWorkspaces": true
}

Context

I want to run the same task on all packages (no fail-fast) and see which packages succeeded and which didn’t.

Your Environment

Executable Version
lerna --version 3.13.1
npm --version 5.6.0
yarn --version 1.13.0
node --version v8.11.3
OS Version
macOS High Sierra 10.13.6

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:23
  • Comments:15 (2 by maintainers)

github_iconTop GitHub Comments

16reactions
buschtoenscommented, Aug 21, 2020

I still believe that this is fundamentally broken. I would expect that --no-bail:

  • still prints all output (including stderr), exactly like without --no-bail
  • runs all scripts, even if one fails
  • prints a summary in the end, where failed packages are logged as such, not as success
  • returns a non-zero exit code, if any package fails
    • if only one package fails, returns that exit code
    • if more than one package fails, exits with 1 (or something else?)

I would really, really like to fix this, as I think --no-bail is basically pretty much useless otherwise, at least to me. Do you think we can / should fix the behavior of --no-bail or rather add a new flag and maybe deprecate --no-bail?

6reactions
lumberjack-danielcommented, Sep 29, 2021

Digging through log files of a huge mono-repo across all packages to determine which package failed is cumbersome.

Instead, something like this would be nice, when --no-bail is used:

timestamp pkg exitcode status
[2021-09-29T20:16:16.299Z] lerna pkg1	0 	success
[2021-09-29T20:16:16.299Z] lerna pkg2   127	failed
[2021-09-29T20:16:16.299Z] lerna pkg3	0  	success
[2021-09-29T20:16:16.299Z] lerna ERR! One or more packages received non-zero exit code during execution
Read more comments on GitHub >

github_iconTop Results From Across the Web

Managing Monorepo using Lerna and Yarn workspaces
lerna run is a command to run npm-scripts in all packages managed by Lerna. For example, the lerna run test command runs npm...
Read more >
How can I get Lerna to tell me which package had failing tests?
Received non-zero exit code 1 during execution lerna success run Ran npm script 'test:ci' in 10 packages in 930.9s: lerna success ...
Read more >
Setting up a monorepo with Lerna for a TypeScript project
You know the benefits of keeping your codebase simple to maintain. Learn how to setup a monorepo with Lerna and configure it for...
Read more >
@lerna/list | Yarn - Package Manager
Now: lerna publish when there are no updates is a no-op, exiting successfully with a helpful log message; lerna updated when there are...
Read more >
Monorepo using Lerna, Conventional commits, and Github ...
Easily manage npm packages versioning, publication, and changelog generation. Tagged with lerna, githubpackages, npm, javascript.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found