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

fix(npm): properly handle lock file maintenance for nested independent yarn workspaces #16451

Merged

Conversation

devversion
Copy link
Contributor

If a separate Yarn "project" is nested inside a project, yarn install
cannot be simply run with Yarn Berry 2+ if there is no lock file.

This check/enforcement makes sense because Yarn 2+ wants to make sure
you either add this as a workspace using their workspaces feature, or
you explicitly opt-in into a dedicated/independent "sub workspace".

Currently when Renovate processes such an independent/isolated
sub-workspace, it removes the yarn.lock for lock file maintancen. This
will then result in the enforcement error when yarn install is
executed to actually re-generate the lock file.

See Yarn's error:

Usage Error: The nearest package directory (/tmp/renovate/repos/github/angular/dev-infra/tools/ts_proto) doesn't seem to be part of the project declared in /tmp/renovate/repos/github/angular/dev-infra.

- If /tmp/renovate/repos/github/angular/dev-infra isn't intended to be a project, remove any yarn.lock and/or package.json file there.
- If /tmp/renovate/repos/github/angular/dev-infra is intended to be a project, it might be that you forgot to list tools/ts_proto in its workspace configuration.
- Finally, if /tmp/renovate/repos/github/angular/dev-infra is fine and you intend tools/ts_proto to be treated as a completely separate project (not even a workspace), create an empty yarn.lock file in it.

We can fix this, preserving the original decision (of the subdirectory
being an independent workspace), by not deleting the lock file, but
rather by just wiping it (to trigger the full regeneration).

Example error PR without the fix:
angular/dev-infra#676 (comment).

How I've tested my work (please tick one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests

Note: Not actually tested in a full runtime, just unit tests which mock out the actual Yarn install though..

…t yarn workspaces

If a separate Yarn "project" is nested inside a project, `yarn install`
cannot be simply run with Yarn Berry 2+ if there is no lock file.

This check/enforcement makes sense because Yarn 2+ wants to make sure
you either add this as a workspace using their workspaces feature, or
you explicitly opt-in into a dedicated/independent "sub workspace".

Currently when Renovate processes such an independent/isolated
sub-workspace, it removes the `yarn.lock` for lock file maintancen. This
will then result in the enforcement error when `yarn install` is
executed to actually re-generate the lock file.

See Yarn's error:

```
Usage Error: The nearest package directory (/tmp/renovate/repos/github/angular/dev-infra/tools/ts_proto) doesn't seem to be part of the project declared in /tmp/renovate/repos/github/angular/dev-infra.

- If /tmp/renovate/repos/github/angular/dev-infra isn't intended to be a project, remove any yarn.lock and/or package.json file there.
- If /tmp/renovate/repos/github/angular/dev-infra is intended to be a project, it might be that you forgot to list tools/ts_proto in its workspace configuration.
- Finally, if /tmp/renovate/repos/github/angular/dev-infra is fine and you intend tools/ts_proto to be treated as a completely separate project (not even a workspace), create an empty yarn.lock file in it.
```

We can fix this, preserving the original decision (of the subdirectory
being an independent workspace), by not deleting the lock file, but
rather by just wiping it (to trigger the full regeneration).

Example error PR without the fix:
angular/dev-infra#676 (comment).
@CLAassistant
Copy link

CLAassistant commented Jul 6, 2022

CLA assistant check
All committers have signed the CLA.

@viceice
Copy link
Member

viceice commented Jul 6, 2022

don't remove parts of PR template

@rarkins rarkins enabled auto-merge (squash) July 6, 2022 20:40
@rarkins rarkins merged commit c892158 into renovatebot:main Jul 6, 2022
@devversion
Copy link
Contributor Author

devversion commented Jul 6, 2022

Thanks for the review @rarkins! 🎉

@rarkins
Copy link
Collaborator

rarkins commented Jul 6, 2022

Great PR, thanks :)

@renovate-release
Copy link
Collaborator

🎉 This PR is included in version 32.105.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

devversion added a commit to devversion/dev-infra that referenced this pull request Jul 10, 2022
devversion added a commit to angular/dev-infra that referenced this pull request Jul 10, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants