{"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":"exception","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/89f33cbef296a2b287f323d42de54c871fa69c77/cli/tools/transpile.rs#L537-L566","documentation":"With `--outdir`, the JS output path is outdir + (input with new extension) relative to cwd; `strip_prefix(cwd)` on the input fails when the input lives outside the current directory, and the error explicitly suggests `--output`, which accepts any path.","triggerScenarios":"`deno transpile --outdir dist ../shared/mod.ts` — an input file not under the current working directory combined with --outdir.","commonSituations":"Invoking from a nested directory with sources above it; CI steps that cd into an output directory before running the tool.","solutions":["Run the command from a common ancestor directory of all inputs","Use --output for a single file regardless of location: `deno transpile ../mod.ts -o out/mod.js`","Omit --outdir entirely — output then lands next to each source file"],"exampleFix":"# before (cwd = packages/one)\ndeno transpile --outdir dist ../shared/mod.ts\n# after\ndeno transpile ../shared/mod.ts --output dist/mod.js","handlingStrategy":"validation","validationCode":"# bash: same cwd guard as the declaration variant\nfor f in \"$@\"; do\n  case \"$(realpath \"$f\")\" in \"$(pwd)\"/*) ;; *) echo \"$f outside cwd — use --output\" >&2; exit 1;; esac\ndone\ndeno transpile --outdir dist \"$@\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run from a common ancestor directory when using --outdir","Use --output for single files outside the tree","Skip --outdir to emit next to sources when layout allows"],"tags":["cli","transpile","outdir","paths"],"backgroundTag":null,"analyzedSha":"89f33cbef296a2b287f323d42de54c871fa69c77","analyzedAt":"2026-08-16T07:54:21.310Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}