{"record":{"id":"980ad9fe735a418f","repo":"vercel/turborepo","slug":"directory-opts-directory-does-not-exist-usin","errorCode":null,"errorMessage":"Directory \"${opts.directory}\" does not exist, using current directory","messagePattern":"Directory \"(.+?)\" does not exist, using current directory","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/turbo-ignore/src/ignore.ts","lineNumber":71,"sourceCode":"    warn(\n      `\\u001B[33m\"turbo-ignore\" is deprecated. Use \"turbo query affected\" instead.\\u001B[39m`\n    );\n    warn(\n      `\\u001B[33mLearn more: https://turborepo.dev/docs/reference/query#migrating-from-turbo-ignore\\u001B[39m\\n`\n    );\n  }\n\n  info(\n    `Using Turborepo to determine if this project is affected by the commit...\\n`\n  );\n\n  // set default directory\n  if (opts.directory) {\n    const directory = path.resolve(opts.directory);\n    if (existsSync(directory)) {\n      inputs.directory = directory;\n    } else {\n      warn(\n        `Directory \"${opts.directory}\" does not exist, using current directory`\n      );\n      inputs.directory = process.cwd();\n    }\n  } else {\n    inputs.directory = process.cwd();\n  }\n\n  // check for TURBO_FORCE and bail early if it's set\n  if (process.env.TURBO_FORCE === \"true\") {\n    info(\"`TURBO_FORCE` detected\");\n    return continueBuild();\n  }\n\n  // find the monorepo root\n  const root = getTurboRoot(inputs.directory);\n  if (!root) {\n    error(\"Monorepo root not found. turbo-ignore inferencing failed\");","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/vercel/turborepo/blob/f9245100cf0d31d96628804ead485f6bf226e55a/packages/turbo-ignore/src/ignore.ts#L53-L89","documentation":"turbo-ignore resolves its --directory option and, when that path does not exist on disk, warns and falls back to process.cwd() for the affected check. The check therefore runs against the current working directory rather than the intended workspace, which can produce a wrong affected/not-affected answer — the more dangerous consequence of the fallback.","triggerScenarios":"Passing `--directory=<dir>` where the resolved path does not exist: a typo, a stale package path after a rename/move, or CI running from an unexpected working directory while supplying a relative path.","commonSituations":"Matrix CI jobs constructing --directory dynamically for packages that were renamed or deleted; scripts assuming a different cwd than the one the step actually runs in.","solutions":["Pass the correct existing path (absolute, or valid relative to the invocation cwd)","Verify the path exists in the CI step before calling turbo-ignore (`test -d \"$DIR\"`)","Remove stale matrix entries for renamed/deleted packages"],"exampleFix":"# before\nturbo-ignore --directory=apps/weeb   # typo\n\n# after\nturbo-ignore --directory=apps/web","handlingStrategy":"validation","validationCode":"# Validate the target directory before turbo-ignore silently falls back to cwd\ndir=\"${PACKAGE_DIR:?unset}\"\n[ -d \"$dir\" ] || { echo \"$dir does not exist\"; exit 1; }\nturbo-ignore --directory=\"$dir\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Resolve --directory against a known root (e.g. \"$GITHUB_WORKSPACE/apps/web\") instead of assuming the cwd","Purge CI matrix entries when packages are renamed or removed","Treat the cwd fallback as dangerous: the affected answer may silently apply to the wrong package"],"tags":["turbo-ignore","directory","path","fallback"],"backgroundTag":"directory-not-found","analyzedSha":"f9245100cf0d31d96628804ead485f6bf226e55a","analyzedAt":"2026-08-17T10:46:15.696Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}