pub fn detect_package_manager(repo_root: &AbsoluteSystemPath) -> Result<Self, Error> {
        let detected_package_managers = PnpmDetector::new(repo_root)
            .chain(NpmDetector::new(repo_root))
            .chain(YarnDetector::new(repo_root))
            .chain(BunDetector::new(repo_root))
            .collect::<Result<Vec<_>, Error>>()?;

        match detected_package_managers.as_slice() {
            [] => Err(NoPackageManager.into()),
            [package_manager] => Ok(package_manager.clone()),
            _ => {
                let managers = detected_package_managers
                    .iter()
                    .map(|mgr| mgr.name().to_string())
                    .collect();
                Err(Error::MultiplePackageManagers { managers })
            }
        }
    }
Try to detect package manager based on configuration files and binaries
installed on the system.
crates/turborepo-repository/src/package_manager/mod.rs