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.

[Bug]: `yarn workspaces foreach` always exits with status 0 even on error

See original GitHub issue

Self-service

  • I’d be willing to implement a fix

Describe the bug

In Yarn@3.0.1, when I run a command with yarn workspaces foreach, it still return as successful even when a workspace process failed.

To reproduce

This is my repro: https://github.com/akphi/issue-repo/pull/1

I setup a test monorepo with 2 workspaces pkg1 and pkg2. Each workspace has a script called doSomething. pkg1 will exit with code 1 since the command error is not known.

At the root directory, if we run the following command, we got some unexpected result:

yarn workspaces foreach run doSomething                                          # no error
yarn workspaces foreach --all run doSomething                                    # no error
yarn workspaces foreach --parallel run doSomething                               # no error
yarn workspaces foreach --all --parallel --topological-dev run doSomething       # error

Environment

System: OS: macOS 11.5.1 CPU: (8) x64 Intel® Core™ i7-4870HQ CPU @ 2.50GHz Binaries: Node: 14.17.1 - /private/var/folders/95/y32364512q77c1dvhkpnr_n80000gn/T/xfs-02ae3755/node Yarn: 3.0.1 - /private/var/folders/95/y32364512q77c1dvhkpnr_n80000gn/T/xfs-02ae3755/yarn npm: 6.14.13 - ~/.nvm/versions/node/v14.17.1/bin/npm npmPackages: jest: 27.0.6 => 27.0.6

Additional context

Related to https://github.com/yarnpkg/berry/issues/2486

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:16

github_iconTop GitHub Comments

1reaction
remolueoendcommented, Apr 19, 2022

Hey @akphi, no worries, that’s why we’re here, glad I could help!

1reaction
remolueoendcommented, Apr 18, 2022

What do you mean by "the failing script swallowed the error`?

Sorry, that was related to a problem in a personal project and why I investigated this issue in the first place. But based on my personal repository and the sherlock tests, this issue seems not reproducible anymore on the newest version (>= 3.2.0). Can you still reproduce it?

Read more comments on GitHub >

github_iconTop Results From Across the Web

@yarnpkg/core | Yarn - Package Manager
... as a JSON object (useful to set server configuration, etc). yarn workspace foreach will now exit with the expected status code if...
Read more >
Download & Update Node.js to the Latest Version! Node v19 ...
Direct download links to update to the latest Node.js versions: Node v19.0.0 / LTS v16.18.0.
Read more >
Blog | HHVM
We provide a Visual Studio Code workspace to develop HHVM. ... a keyset is now always inferred as a subtype of arraykey even...
Read more >
Beware of Colons in Yarn Scripts - DEV Community ‍ ‍
A script with a colon in its name implicitly "exists" in every workspace, so yarn workspaces foreach run will always execute it in...
Read more >
Advanced package manager features for npm, Yarn, and pnpm
Don't think a lot about your package manager? Learn more in this article about the advances in package manager features you may have...
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