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 plugin import workspace-tools is broken??

See original GitHub issue

Self-service

  • I’d be willing to implement a fix

Describe the bug

yarn plugin import workspace-tools command is broken since Sunday (7/25), this command runs successfully. But after that any yarn command throws error

To reproduce

Have .yarnrc.yml and typical yarn2 requirements in your app directory run yarn plugin import workspace-tools >> success yarn --version

this will show this error

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

Yarn Package Manager - 2.4.1

  $ yarn <command>

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

Environment

OS: stretch/debian 9 It runs in github action agents, so dont know much other environment details, I can get those details if needed. But this is repro-ing in local docker container (debian based node 14 image) as well

Additional context

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:15
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
merceyzcommented, Jul 29, 2021

The reason this is happening is that we released Yarn 3.0 and the 3.0 plugins aren’t compatible with Yarn 2.0. We added support for specifying a version when importing plugins in 3.0 and made sure it imports compatible plugins when a version isn’t specified so this shouldn’t be an issue for future releases.

As a workaround you can run this to get the compatible version while staying on yarn@2.4.1

yarn set version berry
yarn plugin import workspace-tools@2.2.0
yarn set version 2.4.1

To repro I used an official node-14 image which comes with yarn 1.22.5. Here is what I ran … yarn set version latest

When you run that with v1 it grabs the latest v1 version, run this instead:

yarn set version berry

but you shouldn’t be running these commands on your CI and/or in Docker builds, you should run it locally once and commit it to your repository.

1reaction
geisterfurz007commented, Jul 29, 2021

The time the plugin broke seems to match the release of plugin version 3.0.0.

Workarounds

Following are two workarounds, pick the one that is more suitable for your usecase.

  1. Upgrade yarn: Upgrading Yarn to 3.0.0 by running yarn set version latest allows you to use the 3.0.0 version installed with yarn plugin import workspace-tools.

  2. Don’t run yarn plugin import workspace-tools in your project anymore: I noticed this issue as well when my Docker builds started breaking over the night. I assume you are not supposed to import plugins again in the CI and instead just once when setting up your project. That’s probably somewhere in the docs but I didn’t search for it. As long as .yarn/plugins and .yarnrc.yml are copied into the container, the plugin should properly get referenced. I removed the plugin import from my Dockerfile and the build worked again, including yarn workspaces focus.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Bug] yarn plugin import resolving problem #722 - GitHub
I'd be willing to implement a fix Describe the bug I couldn't find this reported but ... yarn plugin import @yarnpkg/plugin-workspace-tools.
Read more >
@yarnpkg/plugin-workspace-tools | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >
Migrating our Monorepo to Yarn 2 | DoltHub Blog
Our front-end code lives in a directory within ld called web , which is split up into packages managed with Yarn workspaces.
Read more >
Migrating a monorepo from Lerna to Yarn 3 with PnP and Zero ...
This command come from the workspace-tools plugin I've mentioned. It is using these options: v : verbose, prefix the output with the package ......
Read more >
Yarn 3 typescript plugin not pulling in @types for package.json ...
One plugin yarn recommend for a typescript application is the typescript plugin. Installed via the command yarn plugin import typescript. This ...
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