{"record":{"id":"30d2be30a9f41853","repo":"denoland/deno","slug":"input-file-is-not-under-the-current-directory","errorCode":null,"errorMessage":"Input file {} is not under the current directory. Use --output instead.","messagePattern":"Input file (.+?) is not under the current directory\\. Use --output instead\\.","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"cli/tools/transpile.rs","lineNumber":555,"sourceCode":"  cwd: &Path,\n  output: Option<&str>,\n  output_dir: Option<&str>,\n  media_type: MediaType,\n) -> Result<PathBuf, AnyError> {\n  if let Some(output) = output {\n    // Explicit output file\n    return Ok(cwd.join(output));\n  }\n\n  let ext = js_extension_for_media_type(media_type);\n  let js_filename = input_path.with_extension(ext);\n\n  if let Some(outdir) = output_dir {\n    let outdir = cwd.join(outdir);\n    let relative = js_filename\n      .strip_prefix(cwd)\n      .map_err(|_| {\n        anyhow::anyhow!(\n          \"Input file {} is not under the current directory. Use --output instead.\",\n          input_path.display()\n        )\n      })?;\n    Ok(outdir.join(relative))\n  } else {\n    // Write alongside source file\n    Ok(js_filename)\n  }\n}\n","sourceCodeStart":537,"sourceCodeEnd":566,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/tools/transpile.rs#L537-L566","documentation":"compute_output_path (cli/tools/transpile.rs:550-560) mirrors each input's directory structure under --outdir by stripping the current directory from the output .js path. An input that resolves outside cwd — typically an absolute path from another tree, or a working directory changed via -C while paths are given relative to elsewhere — cannot be stripped, so Deno raises this error and the message itself points you to --output.","triggerScenarios":"deno transpile --outdir dist /opt/other/src/mod.ts (absolute input outside cwd); running with -C elsewhere while passing paths relative to the original directory.","commonSituations":"Build scripts that feed absolute paths collected from find/rg; monorepo builds invoked from a subdirectory; CI checkout layouts where sources live outside the declared cwd.","solutions":["Use --output <file> as the error suggests: single-file mode needs no relative structure.","Run deno from a common ancestor so all inputs sit under the current directory.","Pass inputs as paths relative to the actual cwd instead of absolute paths from another tree."],"exampleFix":"# before\n$ cd app && deno transpile --outdir dist /opt/shared/mod.ts\nerror: Input file /opt/shared/mod.ts is not under the current directory. Use --output instead.\n\n# after\ndeno transpile --output dist/mod.js /opt/shared/mod.ts\n# or: cd /opt && deno transpile --outdir app/dist shared/mod.ts","handlingStrategy":"validation","validationCode":"# Reject inputs outside cwd before choosing --outdir\nfor f in \"$@\"; do\n  p=$(realpath -m \"$f\")\n  [ \"${p#$(pwd)}\" != \"$p\" ] || { echo \"$f is outside cwd — use --output\"; exit 1; }\ndone\ndeno transpile --outdir dist \"$@\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use --output for any input not under the current directory.","Run builds from the repo root so --outdir can mirror the relative structure.","Feed paths relative to the actual cwd instead of absolute paths from another tree."],"tags":["transpile","outdir","path","cli"],"backgroundTag":"path-outside-working-directory","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}