Skip to content

[Bug?]: Adding a portal from a package outside a workspace to one inside fails in 3.2.0 #4160

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

Closed
1 task
spiltcoffee opened this issue Feb 25, 2022 · 5 comments · Fixed by #4206
Closed
1 task
Assignees
Labels
bug Something isn't working node-modules

Comments

@spiltcoffee
Copy link

spiltcoffee commented Feb 25, 2022

Self-service

  • I'd be willing to implement a fix

Describe the bug

I have the following package structure:

  • some-workspace
    • foo
    • bar
  • baz

The dependencies of these packages are as such:

  • some-workspace has a workspaces key listing foo and bar
  • bar has a dependencies entry for "foo": "workspace:*"
  • baz has a dependencies entry for "bar": "portal:../some-workspace/bar"
  • baz has a resolutions entry for "bar/foo": "portal:../some-workspace/foo"

Up to Yarn v3.1.1, this setup worked fine - no errors, no real funkiness.

With Yarn v3.2.0, when I run yarn install inside baz, I'm now seeing an error occur with this kind of setup, along these lines:

➤ YN0001: │ Error: Assertion failed: Writing attempt prevented to /some-workspace/bar/node_modules/foo which is outside project root: /baz

To reproduce

I've created a reproduction here: https://github.com/spiltcoffee/yarn-workspace-portal-issue

Environment

System:
    OS: Windows 10 10.0.19044
    CPU: (8) x64 Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz
  Binaries:
    Node: 16.13.2 - C:\Temp\xfs-82221d88\node.CMD
    Yarn: 3.2.0 - C:\Temp\xfs-82221d88\yarn.CMD
    npm: 8.1.2 - C:\Program Files\nodejs\npm.CMD

Additional context

I've also tried the following in an attempt to fix the issue:

  • Adding a dependency on foo that has the same portal:
  • Adding a packageExtensions key to the .yarnrc.yml
  • Updated to canary (it appears to just be Yarn v3.2.0 at the moment anyway?)
@spiltcoffee spiltcoffee added the bug Something isn't working label Feb 25, 2022
@IU520CF
Copy link

IU520CF commented Mar 7, 2022

How to delete yarn3.2 ?

@spiltcoffee
Copy link
Author

@IU520CF Unsure what you mean? Do you mean how to downgrade to an older version of yarn?

@IU520CF
Copy link

IU520CF commented Mar 8, 2022

Yes, downgrade yarn2

@IU520CF
Copy link

IU520CF commented Mar 8, 2022

I upgraded yarn3 2. I found that I can't use it. Finally, I started it with NPM. The package is bigger

@larixer
Copy link
Member

larixer commented Mar 10, 2022

The issue should be fixed via: #4206
Also, you can work around it by adding nmSelfReferences: false into .yarnrc.yml

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

Successfully merging a pull request may close this issue.

3 participants