Berry: [Bug] Publishing workspaces in CI environments exits with the wrong code

Created on 23 Oct 2020  Â·  6Comments  Â·  Source: yarnpkg/berry

  • [ ] I'd be willing to implement a fix

Describe the bug

I'm running yarn workspaces foreach npm publish in a GitHub Action workflow. When the workflow runs this step, it results in the successful publishing of all workspaces, yet the command exits with an error code of 1. I'm publishing the packages to a private registry, I don't know if the bug is also present in case of a public one.

Some logs:

Run yarn workspaces foreach npm publish
  yarn workspaces foreach npm publish
  shell: /bin/bash -e {0}
➤ YN0000: Usage Error: Private workspaces cannot be published
➤ YN0000: 
➤ YN0000: $ yarn npm publish [--access #0] [--tag #0] [--tolerate-republish]
➤ YN0000: ➤ YN0000: README.md
...
➤ YN0000: ➤ YN0000: package.json
➤ YN0000: ➤ YN0000: Package archive published
➤ YN0000: ➤ YN0000: Done in 1.35s
➤ YN0000: Done in 23.85s
Error: Process completed with exit code 1.

To Reproduce

  1. Set up a monorepo with multiple workspaces.
  2. Create a GitHub Actions workflow that runs the command yarn workspaces foreach npm publish in one of its steps.
  3. See how it exits with exit code 1 after successfully publishing all workspaces.

Screenshots

If applicable, add screenshots to help explain your problem.

Environment if relevant (please complete the following information):

  • OS: Linux version 5.3.0-1032-aws (buildd@lgw01-amd64-026) (gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)) #34~18.04.2-Ubuntu SMP as given by cat /proc/version
  • Node version 12.16.1
  • Yarn version 2.0.0-rc.36

Additional context

Add any other context about the problem here.

bug not a bug

Most helpful comment

It's trying to publish the root (private) workspace, you need to exclude it

@merceyz how do I exclude it?

You can exclude it using --no-private, https://yarnpkg.com/cli/workspaces/foreach#options-private

yarn workspaces foreach --no-private npm publish

All 6 comments

➤ YN0000: Usage Error: Private workspaces cannot be published

That sounds like an error 🙂

It's trying to publish the root (private) workspace, you need to exclude it

@arcanis I get a similar (if not the same) output on my machine but the command exits with 0. This error refers to the case when yarn workspaces foreach invokes the command for the top-level/root workspace.

It's trying to publish the root (private) workspace, you need to exclude it

@merceyz how do I exclude it?

It's trying to publish the root (private) workspace, you need to exclude it

@merceyz how do I exclude it?

You can exclude it using --no-private, https://yarnpkg.com/cli/workspaces/foreach#options-private

yarn workspaces foreach --no-private npm publish

@merceyz thank you, it worked with --no-private 🙂

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Santas picture Santas  Â·  3Comments

benwainwright picture benwainwright  Â·  3Comments

Bessonov picture Bessonov  Â·  4Comments

janicduplessis picture janicduplessis  Â·  4Comments

larixer picture larixer  Â·  4Comments