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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

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.

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 owned-by: turborepo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants