这是indexloc提供的服务,不要输入任何密码
Skip to content

Turbo prune removes necessary packages and snapshots of hard linked deps from pnpm-lock.yaml when inject-workspace-packages=true #11059

@moderj

Description

@moderj

Verify canary release

  • I verified that the issue exists in the latest Turborepo canary release.

Link to code that reproduces this issue

repro

Which canary version will you have in your reproduction?

2.6.1-canary.1

Environment information


Expected behavior

turbo prune should be able to keep necessary packages and snapshots in the lockfile, when hard links exist.
I've also created a reproduction

Actual behavior

Hard linked deps are being removed after turbo prune.
This causes pnpm install --frozen-lockfile to fail

To Reproduce

written in the repro README.md

Additional context

I dug into the turborepo code and I think it's something with the pruned_packages_and_snapshots function
it seems like it tries to handle injected workspaces but it looks like it handles only meta.injected which is no longer the only way in pnpm to have hardlinks.
A snapshot of the code that I think might cause the problem

        let (mut pruned_packages, pruned_snapshots) =
            self.pruned_packages_and_snapshots(packages)?;
        for importer in importers.values() {
            // Find all injected packages in each workspace and include it in
            // the pruned lockfile
            for dependency in
                importer
                    .dependencies_meta
                    .iter()
                    .flatten()
                    .filter_map(|(dep, meta)| match meta.injected {
                        Some(true) => Some(dep),
                        _ => None,
                    })
            {
                let (_, version) = importer
                    .dependencies
                    .find_resolution(dependency)
                    .ok_or_else(|| Error::MissingInjectedPackage(dependency.clone()))?;

                let entry = self
                    .get_packages(version)
                    .ok_or_else(|| crate::Error::MissingPackage(version.into()))?;
                pruned_packages.insert(version.to_string(), entry.clone());
            }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions