Yarn Berry "yarn workspaces focus" missing plugin in CI
yarn workspaces focus installs only one workspace and its dependencies, which speeds up CI for a single package. It lives in the workspace-tools plugin; without that plugin, Yarn does not know the command.
What this error means
A CI step running yarn workspaces focus <pkg> fails with "Usage Error: Couldn't find the workspaces focus command" or an unknown-command error.
Usage Error: Couldn't find a script named "focus".
$ yarn workspaces focus @acme/api --productionCommon causes
The workspace-tools plugin is not installed
workspaces focus is not built in; the @yarnpkg/plugin-workspace-tools plugin must be imported to add it.
The plugin was added locally but not committed
The plugin lives in .yarn/plugins and its reference in .yarnrc.yml; if not committed, CI lacks it.
How to fix it
Add and commit the workspace-tools plugin
- Run
yarn plugin import workspace-tools. - Commit
.yarn/pluginsand the updated.yarnrc.yml. - CI can then run
yarn workspaces focus.
yarn plugin import workspace-tools
git add .yarn/plugins .yarnrc.ymlFocus a single workspace in CI
Once the plugin is present, install just the target workspace and its production deps to cut install time.
- run: yarn workspaces focus @acme/api --productionHow to prevent it
- Commit
.yarn/pluginsand.yarnrc.ymlso plugins are available in CI. - Import
workspace-toolsbefore relying onworkspaces focus. - Use
focusto install only what a job needs.