{"record":{"id":"a68d3df8636d6dfe","repo":"denoland/deno","slug":"no-target-files-found","errorCode":null,"errorMessage":"No target files found.","messagePattern":"No target files found\\.","errorType":"validation","errorClass":"AnyError","httpStatus":null,"severity":"error","filePath":"cli/tools/fmt.rs","lineNumber":205,"sourceCode":"  maybe_show_format_confirmation(cli_options, fmt_flags)?;\n\n  let members_fmt_options =\n    cli_options.resolve_fmt_options_for_members(fmt_flags)?;\n  let mut paths_with_options_batches =\n    Vec::with_capacity(members_fmt_options.len());\n  for (_ctx, member_fmt_options) in members_fmt_options {\n    let files =\n      collect_fmt_files(cli_options, member_fmt_options.files.clone());\n    if !files.is_empty() {\n      paths_with_options_batches.push(PathsWithOptions {\n        base: member_fmt_options.files.base.clone(),\n        paths: files,\n        options: member_fmt_options,\n      });\n    }\n  }\n  if paths_with_options_batches.is_empty() && !fmt_flags.permit_no_files {\n    return Err(anyhow!(\"No target files found.\"));\n  }\n  Ok(paths_with_options_batches)\n}\n\nfn maybe_show_format_confirmation(\n  cli_options: &CliOptions,\n  fmt_flags: &FmtFlags,\n) -> Result<(), AnyError> {\n  if fmt_flags.check\n    || !fmt_flags.files.include.is_empty()\n    || cli_options.workspace().deno_jsons().next().is_some()\n    || cli_options.workspace().package_jsons().next().is_some()\n  {\n    return Ok(());\n  }\n\n  let confirm_result =\n    util::console::confirm(util::console::ConfirmOptions {","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/tools/fmt.rs#L187-L223","documentation":"`deno fmt` collects the files it will format from the workspace members (respecting each member's fmt.files include/exclude config). If every member's collection comes back empty and --permit-no-files was not passed, fmt refuses to run at all — this error. It exists so scripts and CI fail loudly when their include patterns silently match nothing, instead of formatting zero files and reporting success.","triggerScenarios":"Running `deno fmt` in a directory with no formattable files (no .ts/.js/.json/... after excludes), or with deno.json fmt exclude patterns / explicit path arguments that filter everything out, without --permit-no-files. The same guard exists in deno lint/bench/test behind their own permit_no_files flags.","commonSituations":"A generated project where all sources live in an excluded directory (vendor/, gen/); CI where the checkout step failed silently so there are no files; passing an extension argument that matches nothing (deno fmt --ext ts in a pure-.md repo); fmt.files includes a directory name that was renamed.","solutions":["If zero files is expected (skeleton repo, CI job that may have nothing to format), add --permit-no-files so an empty set is OK.","Otherwise check what fmt would see: run `deno fmt --check` with the same args, or list matches via `deno fmt` without an enclosing deno.json excludes; fix the include/exclude config in deno.json (\"fmt\": { \"files\": { ... } }).","Verify you are running from the workspace root and the files actually exist (a failed checkout or wrong working dir matches nothing).","Check explicit path arguments for typos — a wrong path filters to empty just like an exclude."],"exampleFix":"# before\ndeno fmt\n# error: No target files found.\n\n# after — if empty is legitimate:\ndeno fmt --permit-no-files\n# after — if files should have matched, fix the config:\n# deno.json: { \"fmt\": { \"exclude\": [\"vendor\"] } } -> narrow the exclude so src/ matches","handlingStrategy":"validation","validationCode":"# In CI, either assert there is something to format, or permit empty explicitly\nif find . -name '*.ts' -o -name '*.js' | grep -q .; then\n  deno fmt --check\nelse\n  deno fmt --check --permit-no-files   # empty workspace is fine\nfi","typeGuard":null,"tryCatchPattern":"In scripts, run fmt with --permit-no-files only when an empty file set is acceptable; otherwise catch the 'No target files found.' exit and fail loudly — it usually means the checkout or include config broke, which you want to know about.","preventionTips":["Add --permit-no-files to CI fmt/lint/bench/test steps where repositories may legitimately have no matching files.","After renaming directories, re-check the fmt.files include/exclude config in deno.json — stale paths silently match nothing.","Treat a sudden 'No target files found.' in CI as a red flag for a failed checkout step, not as a formatting problem."],"tags":["fmt","cli","configuration","ci"],"backgroundTag":"no-input-files-matched","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"}