Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] workspace-tools foreach doesn't run each workspace for node 15 #2214

Closed
1 task
astahmer opened this issue Dec 5, 2020 · 4 comments · Fixed by #2255
Closed
1 task

[Bug] workspace-tools foreach doesn't run each workspace for node 15 #2214

astahmer opened this issue Dec 5, 2020 · 4 comments · Fixed by #2255
Labels
bug Something isn't working

Comments

@astahmer
Copy link

astahmer commented Dec 5, 2020

  • I'd be willing to implement a fix

Describe the bug

Running yarn workspaces foreach -A run script_name only runs script_name on one workspace (even with script_name defined in other workspaces).

To Reproduce

https://github.com/astahmer/yarn-2-foreach-bug

Environment if relevant (please complete the following information):

  • OS: MacOS Catalina 10.15.7
  • Node version Node 15.x
  • Yarn version 2.x

Additional context

Just adding a reproduction repository for this issue

@astahmer astahmer added the bug Something isn't working label Dec 5, 2020
@merceyz
Copy link
Member

merceyz commented Dec 31, 2020

Fixed in #2255, you can test it by running yarn set version from sources or downloading the bundle from the CI

@zzeni
Copy link

zzeni commented Mar 2, 2021

Hi @merceyz , I'm trying to get through the same problem, but once I build yarn from sources it just crashes with the following error:

Usage Error: This plugin cannot access the package referenced via yup which is neither a builtin, nor an exposed entry (when initializing @yarnpkg/plugin-workspace-tools, defined in <path-to-project-root>/.yarnrc.yml)

My setup is OSX 10.15.7, node 15.8.0 and yarn berry.

I've tried on a blank project and got exactly the same error.

Here's how it can be reproduced:

Project contents:

└─ ▶ ls -a test-yarn/
.		..		package.json	ws-1		ws-2
└─ ▶ ls -a test-yarn/ws-*
test-yarn/ws-1:
.		..		package.json

test-yarn/ws-2:
.		..		package.json
└─ ▶ cat test-yarn/* test-yarn/**/*
{
  "name": "test-yarn",
  "private": true,
  "workspaces": [
    "./*"
  ]
}
cat: test-yarn/ws-1: Is a directory
cat: test-yarn/ws-2: Is a directory
# test-yarn/ws-1/package.json
{
  "name": "ws-1",
  "scripts": {
    "name": "echo \"I am ws-1\""
  }
}
# test-yarn/ws-2/package.json
{
  "name": "ws-2",
  "scripts": {
    "name": "echo \"I am ws-2\""
  }
}

Then:

└─ ▶ cd test-yarn
└─ ▶ node -v
v15.8.0
└─ ▶ yarn -v
1.22.10
└─ ▶ yarn set version berry
Resolving berry to a url...
Downloading https://github.com/yarnpkg/berry/raw/master/packages/berry-cli/bin/berry.js...
Saving it into /Users/e.manolova/Projects/test-yarn/.yarn/releases/yarn-berry.cjs...
Updating /Users/e.manolova/Projects/test-yarn/.yarnrc.yml...
Done!
└─ ▶ yarn -v
2.4.0
└─ ▶ yarn set version from sources
➤ YN0000: Fetching the latest commits

  $ git fetch origin master --force
  $ git reset --hard FETCH_HEAD
  $ git clean -dfx

➤ YN0000: Building a fresh bundle

➤ YN0000: ┌ Building the CLI
➤ YN0000: │ pnp:/private/var/folders/2k/nvccvbw52jsbk_rgsz8jz00c__qdjl/T/yarnpkg-sources/d0a670/.yarn/cache/keyv-npm-4.0.0-941f620aa2-cd446a9a97.zip/node_modules/keyv/src/index.js:18:14
➤ YN0000: │    ↳ This call to "require" will not be bundled because the argument is not a string literal (surround with a try/catch to silence this warning)
➤ YN0000: └ Completed in 4s 500ms

➤ YN0000: ✓ Done building the CLI!
➤ YN0000: ? Bundle path: /private/var/folders/2k/nvccvbw52jsbk_rgsz8jz00c__qdjl/T/yarnpkg-sources/d0a670/packages/yarnpkg-cli/bundles/yarn.js
➤ YN0000: ? Bundle size: 1.85 MB

➤ YN0000: → @yarnpkg/plugin-essentials
➤ YN0000: → @yarnpkg/plugin-compat
➤ YN0000: → @yarnpkg/plugin-dlx
➤ YN0000: → @yarnpkg/plugin-file
➤ YN0000: → @yarnpkg/plugin-git
➤ YN0000: → @yarnpkg/plugin-github
➤ YN0000: → @yarnpkg/plugin-http
➤ YN0000: → @yarnpkg/plugin-init
➤ YN0000: → @yarnpkg/plugin-link
➤ YN0000: → @yarnpkg/plugin-node-modules
➤ YN0000: → @yarnpkg/plugin-npm
➤ YN0000: → @yarnpkg/plugin-npm-cli
➤ YN0000: → @yarnpkg/plugin-pack
➤ YN0000: → @yarnpkg/plugin-patch
➤ YN0000: → @yarnpkg/plugin-pnp

➤ YN0000: Saving the new release in .yarn/releases/yarn-sources.cjs
➤ YN0000: Done in 14s 621ms
└─ ▶ yarn -v
2.4.0-git.20210302.hash-9d3e1d2b
└─ ▶ yarn
➤ YN0000: ┌ Resolution step
➤ YN0000: └ Completed
➤ YN0000: ┌ Fetch step
➤ YN0000: └ Completed
➤ YN0000: ┌ Link step
➤ YN0000: └ Completed
➤ YN0000: Done in 0s 42ms
└─ ▶ yarn workspaces list
➤ YN0000: .
➤ YN0000: ws-1
➤ YN0000: ws-2
➤ YN0000: Done in 0s 2ms
└─ ▶ yarn plugin import workspace-tools
➤ YN0000: Downloading https://github.com/yarnpkg/berry/raw/master/packages/plugin-workspace-tools/bin/%40yarnpkg/plugin-workspace-tools.js
➤ YN0000: Saving the new plugin in .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
➤ YN0000: Done in 1s 362ms
└─ ▶ yarn
Usage Error: This plugin cannot access the package referenced via yup which is neither a builtin, nor an exposed entry (when initializing @yarnpkg/plugin-workspace-tools, defined in /Users/e.manolova/Projects/test-yarn/.yarnrc.yml)

━━━ Yarn Package Manager - 2.4.0-git.20210302.hash-9d3e1d2b ━━━━━━━━━━━━━━━━━━━━━

  $ yarn <command>

You can also print more details about any of these commands by calling them with
the `-h,--help` flag right after the command name.

Please, let me know if this is not related to the current thread and I can open a new issue.

Thanks! ☺️

@merceyz
Copy link
Member

merceyz commented Mar 2, 2021

When you import the CLI from sources you need to import the plugin from it as well

yarn plugin import from sources workspace-tools

@zzeni
Copy link

zzeni commented Mar 2, 2021

Oh, that worked like a charm. Thanks! :)

When you import the CLI from sources you need to import the plugin from it as well

yarn plugin import from sources workspace-tools

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants