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

[Working as intended] relative paths inside protocols inside packageExtensions are resolved relative to the parent package's location #1127

Closed
goszczynskip opened this issue Mar 27, 2020 · 1 comment
Labels
working as intended The current behavior is intended.

Comments

@goszczynskip
Copy link

goszczynskip commented Mar 27, 2020

Describe the bug

Patching fails with: ENOENT: no such file or directory, open './foo.patch' when trying to install with nodeLinker: "node-modules" set.

To Reproduce

Repo with example: https://github.com/goszczynskip/yarn-berry-bug-patch

Steps that I made:

  • created yarn repo
  • set nodeLinker to node-modules EDIT: with pnp it fails too
  • patched watchpack from webpack
  • add webpack to dependencies
  • run yarn

Environment if relevant (please complete the following information):

  • OS: Windows 10
  • Node version v13.2.0
  • Yarn version 2.0.0-rc.31 and sources
@goszczynskip goszczynskip added the bug Something isn't working label Mar 27, 2020
@goszczynskip goszczynskip changed the title [Bug] Can't patch dependency when nodeLinker is set to node-modules [Bug] Can't patch dependency Mar 27, 2020
@paul-soporan paul-soporan changed the title [Bug] Can't patch dependency [Bug] patch: and file: protocols don't work with relative paths in packageExtensions Apr 18, 2020
@paul-soporan paul-soporan added working as intended The current behavior is intended. and removed bug Something isn't working labels Apr 18, 2020
@paul-soporan
Copy link
Member

(Thanks to @arcanis for explaining this to me first. 😄)

The current behavior is intended. This is kind of an edge case that affects all of the protocols that accept paths (patch:, file:, portal: etc.).

Dependencies declared through the packageExtensions field simply replace a package's dependencies, so relative paths are resolved relative to the path of the original package (in this case the root of the zip archive containing the package).
On the other hand, if the resolutions field contains dependencies with protocols with relative paths, they will be resolved relative to the project (your project's) root.

In short:

  • The resolutions field should be used to override dependencies already declared (i.e. to apply your custom fixes).
  • The packageExtensions field should be used to add undeclared dependencies.

I'll add a note about this in the description of the resolutions field.

@paul-soporan paul-soporan changed the title [Bug] patch: and file: protocols don't work with relative paths in packageExtensions [Working as intended] relative paths inside protocols inside packageExtensions are resolved relative to the parent package's location Apr 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
working as intended The current behavior is intended.
Projects
None yet
Development

No branches or pull requests

2 participants