{"record":{"id":"722034258ecfe5f8","repo":"vercel/turborepo","slug":"package-manager-unexpected-722034","errorCode":"package_manager-unexpected","errorMessage":"Not a yarn project","messagePattern":"Not a yarn project","errorType":"exception","errorClass":"ConvertError","httpStatus":null,"severity":"error","filePath":"packages/turbo-workspaces/src/managers/yarn.ts","lineNumber":58,"sourceCode":" */\n// eslint-disable-next-line @typescript-eslint/require-await -- must match the detect type signature\nasync function detect(args: DetectArgs): Promise<boolean> {\n  const lockFile = path.join(args.workspaceRoot, PACKAGE_MANAGER_DETAILS.lock);\n  const packageManager = getWorkspacePackageManager({\n    workspaceRoot: args.workspaceRoot\n  });\n  return (\n    fs.existsSync(lockFile) || packageManager === PACKAGE_MANAGER_DETAILS.name\n  );\n}\n\n/**\n  Read workspace data from yarn workspaces into generic format\n*/\nasync function read(args: ReadArgs): Promise<Project> {\n  const isYarn = await detect(args);\n  if (!isYarn) {\n    throw new ConvertError(\"Not a yarn project\", {\n      type: \"package_manager-unexpected\"\n    });\n  }\n\n  const packageJson = getPackageJson(args);\n  const { name, description } = getWorkspaceInfo(args);\n  const workspaceGlobs = parseWorkspacePackages({\n    workspaces: packageJson.workspaces\n  });\n  return {\n    name,\n    description,\n    packageManager: PACKAGE_MANAGER_DETAILS.name,\n    paths: expandPaths({\n      root: args.workspaceRoot,\n      lockFile: PACKAGE_MANAGER_DETAILS.lock\n    }),\n    workspaceData: {","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/vercel/turborepo/blob/9f94a7d215b3881942527dd526afa3fc650869d5/packages/turbo-workspaces/src/managers/yarn.ts#L40-L76","documentation":"Thrown by the yarn manager handler's read() in turbo-workspaces when yarn's detect() returns false. Detection means: yarn.lock exists OR the packageManager/devEngines.packageManager field declares yarn (both classic and berry count - the handler does not distinguish them). ConvertError type \"package_manager-unexpected\".","triggerScenarios":"Calling MANAGERS.yarn.read({ workspaceRoot }) directly when there is no yarn.lock and no yarn declaration; via getWorkspaceDetails()/convert() only when yarn.lock or the declaration vanishes between detect() and read() (concurrent git operation, clean script, editor save).","commonSituations":"Yarn Berry projects that do not commit yarn.lock or use a non-standard install; the packageManager field stripped by a merge conflict resolution or removed when someone disabled corepack; wrong workspaceRoot passed (sub-package directory instead of the repo root that owns yarn.lock); assuming a yarn global install means the project is yarn-managed.","solutions":["Ensure yarn.lock exists at the root (run `yarn install`) or add \"packageManager\": \"yarn@<version>\" (e.g. yarn@4.1.0 or yarn@1.22.x) / devEngines.packageManager declaration to package.json","Use getWorkspaceDetails({ root }) instead of MANAGERS.yarn.read so detection picks the manager whose artifacts actually exist","Commit yarn.lock (or at least keep it present during migration) so detection has a stable marker","Avoid mutating the repo (clean/checkout) while a conversion is running"],"exampleFix":"// before\nconst project = await MANAGERS.yarn.read({ workspaceRoot: root });\n\n// after\nif (await MANAGERS.yarn.detect({ workspaceRoot: root })) {\n  const project = await MANAGERS.yarn.read({ workspaceRoot: root });\n}","handlingStrategy":"validation","validationCode":"import { MANAGERS } from \"turbo-workspaces\";\nimport { existsSync } from \"node:fs\";\nimport path from \"node:path\";\n\nif (!existsSync(path.join(root, \"yarn.lock\"))) {\n  throw new Error(`${root} has no yarn.lock - not a yarn project`);\n}\nconst project = await MANAGERS.yarn.read({ workspaceRoot: root });","typeGuard":"import { ConvertError } from \"turbo-workspaces\";\n\nfunction isPackageManagerUnexpected(err: unknown): err is ConvertError {\n  return err instanceof ConvertError && err.type === \"package_manager-unexpected\";\n}","tryCatchPattern":"try {\n  const project = await MANAGERS.yarn.read({ workspaceRoot: root });\n} catch (err) {\n  if (err instanceof ConvertError && err.type === \"package_manager-unexpected\") {\n    project = await getWorkspaceDetails({ root });\n  } else {\n    throw err;\n  }\n}","preventionTips":["Commit yarn.lock (classic and berry alike) so detection is stable","Declare \"packageManager\": \"yarn@<version>\" as a fallback marker","Use getWorkspaceDetails for discovery rather than assuming yarn","Keep corepack/packageManager field intact through merges"],"tags":["yarn","workspaces","package-manager-detection","migration","convert"],"backgroundTag":"wrong-package-manager","analyzedSha":"9f94a7d215b3881942527dd526afa3fc650869d5","analyzedAt":"2026-08-16T19:47:29.531Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}