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(turborepo): add berry support for built meta when pruning #8550

Closed

Conversation

vinnymac
Copy link
Contributor

Description

Add support for yarn berry built option for dependencies meta to turbo prune.

Without this change, yarn install --immutable fails because built is added after turbo accidentally removes it, triggering the following error.

The lockfile would have been modified by this install, which is explicitly forbidden.

Testing Instructions

  • Add a dependenciesMeta for a package and set it to built: false.
  • Run yarn to generate a new lockfile
  • Use turbo prune to produce a slim lockfile
  • Run yarn install --immutable on that small lockfile

@vinnymac vinnymac requested a review from a team as a code owner June 20, 2024 16:14
@turbo-orchestrator turbo-orchestrator bot added needs: triage New issues get this label. Remove it after triage owned-by: turborepo labels Jun 20, 2024
Copy link

vercel bot commented Jun 20, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
examples-nonmonorepo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 30, 2024 6:46pm
rust-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 30, 2024 6:46pm
8 Skipped Deployments
Name Status Preview Comments Updated (UTC)
examples-basic-web ⬜️ Ignored (Inspect) Visit Preview Jul 30, 2024 6:46pm
examples-designsystem-docs ⬜️ Ignored (Inspect) Visit Preview Jul 30, 2024 6:46pm
examples-gatsby-web ⬜️ Ignored (Inspect) Visit Preview Jul 30, 2024 6:46pm
examples-kitchensink-blog ⬜️ Ignored (Inspect) Visit Preview Jul 30, 2024 6:46pm
examples-native-web ⬜️ Ignored (Inspect) Visit Preview Jul 30, 2024 6:46pm
examples-svelte-web ⬜️ Ignored (Inspect) Visit Preview Jul 30, 2024 6:46pm
examples-tailwind-web ⬜️ Ignored (Inspect) Visit Preview Jul 30, 2024 6:46pm
examples-vite-web ⬜️ Ignored (Inspect) Visit Preview Jul 30, 2024 6:46pm

Copy link

vercel bot commented Jun 20, 2024

@vinnymac is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

@chris-olszewski chris-olszewski self-assigned this Jun 20, 2024
@chris-olszewski
Copy link
Member

Thanks for the PR! I think this looks good to me, but I'll be doing some additional testing just because yarn install --immutable is quite strict.

Copy link
Member

@chris-olszewski chris-olszewski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR!

@ijjk
Copy link
Member

ijjk commented Jun 20, 2024

Allow CI Workflow Run

  • approve CI run for commit: 8186f10

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

@@ -163,6 +163,9 @@ where

for (dependency, meta) in metadata {
let dependency = dependency.as_ref();
if meta.built.unwrap_or_default() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I missed this, I believe this logic needs to be changed so we only include built if it is present. add_line will also need to be updated to be able to write both true and false.

Suggested change
if meta.built.unwrap_or_default() {
if meta.built.unwrap_or_default() {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated it so all three dependencyMeta settings support true and false. And check if they are present before adding the lines.

Let me know if you find any more 🐛 s. 🙇🏼‍♂️

if let Some(optional) = meta.optional {
add_line(dependency, "optional", optional);
}
if let Some(unplugged) = meta.unplugged {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After updating this for built, I assumed someone may set optional or unplugged to false, and then that too would become an issue.

@vinnymac
Copy link
Contributor Author

@chris-olszewski fixed an issue with this change where I somehow forgot to support more than one dependency meta setting for a single dependency 😅. This should do the job now, let me know what you think.

@anthonyshew
Copy link
Contributor

@vinnymac @chris-olszewski Just want to check in with you both to see if we want to finish up this PR? I'm doing some housekeeping to close out stale items in the repo (but would love to see this get merged!)

@vinnymac
Copy link
Contributor Author

@vinnymac @chris-olszewski Just want to check in with you both to see if we want to finish up this PR? I'm doing some housekeeping to close out stale items in the repo (but would love to see this get merged!)

This is in a good place, just needs a review first so it can move forward. @chris-olszewski did you want any changes here?

chris-olszewski added a commit that referenced this pull request Dec 11, 2024
…runing (#9605)

### Description

A rebase of #8550 as rebasing
those commits past #8813. I do
not know exactly what about that change resulted in my repo getting into
such a bad state, but I needed to do a fresh clone after trying to
rebase past it.

From the original PR:
Add support for [yarn berry built
option](https://yarnpkg.com/configuration/manifest#dependenciesMeta.built)
for dependencies meta to turbo prune.

Without this change, yarn install --immutable fails because built is
added after turbo accidentally removes it, triggering the following
error.

> The lockfile would have been modified by this install, which is
explicitly forbidden.

All credit to @vinnymac for the original PR

#### Additional Changes

I added some additional unit tests and reworked the `dependenciesMeta`
serialization logic so it support multiple fields per dependency.

### Testing Instructions

Added unit test along with updating the roundtrip text fixture to
include a dependency with `built: false`
@chris-olszewski
Copy link
Member

I needed to manually cherrypick the commits to #9605 as for whatever reason trying to rebase past #8813 was causing git to fail.

Thank you for your contribution and sorry for the delay on getting this merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: triage New issues get this label. Remove it after triage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants