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 nested workspaces feature conflicts with sandboxed build systems

See original GitHub issue

Bug description:

Nested workspaces don’t play nice with sandboxed build systems. If the build directory is stored in a subdirectory in the repo (and that’s often the case), yarn will not allow running commands inside it because it will detect the “package.json” in the repo above and will complain that the build directory is not a workspace of the project.

Repro steps:

  1. Create a yarn monorepo with workspaces: ['packages/*']
  2. Add some package inside packages/
  3. mkdir .build in the project root
  4. Now copy the whole project into the .build directory
  5. cd into .build and run yarn

You will get an error looking roughly like this:

Usage Error: This command can only be run from within a workspace of your project (plz-out/tmp/third_party/yarn_registry/build_registry._build isn't a workspace of /Users/snowak/test_repo/package.json).

Environment:

  • OS: macOS
  • Node version: v13.11.0
  • Yarn version: 2.0.0-rc.30

Additional context

I’m not actually sure how it could be resolved and whether it should be resolved. Nevertheless, it’s a real issue I encountered when trying out the Please build system, so it’s going to bite other people too.

Perhaps there should be a CLI argument that would allow providing the project root path manually? This way yarn wouldn’t keep looking upwards and wouldn’t find the actual repo.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
sebastian-nowakcommented, Mar 20, 2020

That’s certainly a valid option, but speaking from the perspective of a user who encountered this issue - I had no idea the error list page exists but I did read the article about workspaces thoroughly. I knew what the error meant so I didn’t have to look it up, I was looking for a solution, not an explanation of the error. I knew I needed a way to set “boundaries” on the folder structure for workspaces, so I went to the article about workspaces.

Anyway, that’s my way of approaching problems, I’m sure others do it differently so ideally the escape hatch would be mentioned in both places 😃

1reaction
sebastian-nowakcommented, Mar 17, 2020

Thanks @arcanis, the solution you suggested worked for me.

It would be great if this feature was documented somewhere on this page: https://yarnpkg.com/features/workspaces

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using resolutions inside a workspace inner package doesn ...
It seems that yarn add (and yarn upgrade , yarn upgrade-interactive , with or without --latest ) do not respect resolutions, and create...
Read more >
Workspaces
Workspaces are a new way to set up your package architecture that's available by default starting from Yarn 1.0. It allows you to...
Read more >
Nixpkgs 22.11 manual
Nix expressions describe how to build packages from source and are collected in the nixpkgs repository. Also included in the collection are Nix...
Read more >
Configuring Jest
Make sure it is installed in your project. The configuration also can be stored in a JSON file as a plain object: jest.config.json....
Read more >
Announcing Yarn 1.0 - Engineering at Meta - Facebook
Moreover, Yarn will create symlinks between all Workspaces that ... With the new auto-merge feature in Yarn, when there's a merge conflict ......
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