{"record":{"id":"cb08d617047dafab","repo":"denoland/deno","slug":"did-not-format-non-workspace-directory-run-again","errorCode":null,"errorMessage":"Did not format non-workspace directory. Run again specifying the current directory (ex. `deno fmt .`)","messagePattern":"Did not format non-workspace directory\\. Run again specifying the current directory \\(ex\\. `deno fmt \\.`\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/tools/fmt.rs","lineNumber":235,"sourceCode":"    || 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 {\n      default: true,\n      message: format!(\n        \"{} It looks like you're not in a workspace. Are you sure you want to format the entire '{}' directory?\",\n        colors::yellow(\"Warning\"),\n        cli_options.initial_cwd().display()\n      ),\n    })\n    .unwrap_or(false);\n  if confirm_result {\n    Ok(())\n  } else {\n    bail!(\n      \"Did not format non-workspace directory. Run again specifying the current directory (ex. `deno fmt .`)\"\n    )\n  }\n}\n\nasync fn format_files(\n  caches: &Arc<Caches>,\n  cli_options: &Arc<CliOptions>,\n  fmt_flags: &FmtFlags,\n  paths_with_options_batches: Vec<PathsWithOptions>,\n) -> Result<(), AnyError> {\n  let formatter: Box<dyn Formatter> = if fmt_flags.check {\n    let fail_fast = fmt_flags.fail_fast || cli_options.is_quiet();\n    Box::new(CheckFormatter::new(fail_fast))\n  } else {\n    Box::new(RealFormatter::default())\n  };\n  let editorconfig_cache = Arc::new(EditorConfigCache::new());","sourceCodeStart":217,"sourceCodeEnd":253,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/tools/fmt.rs#L217-L253","documentation":"Thrown by `deno fmt` when it is run with no path arguments in a directory that is not part of a Deno workspace (no deno.json/deno.jsonc at or above the cwd). Deno warns that the entire directory will be formatted and asks for confirmation; if the prompt is declined, or stdin is not an interactive TTY so the confirm call returns false, formatting is aborted with this bail.","triggerScenarios":"Running bare `deno fmt` outside any workspace and answering 'n' to the yellow warning prompt; running `deno fmt` in CI or in a script where stdin is a pipe (not a TTY), so util::console::confirm resolves to its unwrap_or(false) default; running fmt from a parent/home directory that has no deno config.","commonSituations":"Fresh projects without a deno.json yet; running fmt from the wrong shell cwd; CI pipelines where the confirmation prompt cannot be answered and silently auto-declines.","solutions":["Run `deno fmt .` (or `deno fmt <path>`) — an explicit path skips the confirmation entirely","Create a deno.json or deno.jsonc at the project root so the directory becomes a workspace","cd into the actual project directory before running `deno fmt`"],"exampleFix":"# before\ndeno fmt   # not in a workspace, prompt auto-declines in CI\n\n# after\ndeno fmt .  # explicit path, no prompt\n\n# or make the directory a workspace:\necho '{ \"fmt\": {} }' > deno.json","handlingStrategy":"validation","validationCode":"# in scripts/CI, always pass an explicit path and require a workspace config:\ntest -f deno.json || test -f deno.jsonc || { echo 'no deno.json: create one first'; exit 1; }\ndeno fmt .   # explicit path never triggers the confirmation","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never invoke bare `deno fmt` in scripts or CI — always `deno fmt <path>`","Keep a deno.json/deno.jsonc at every project root so fmt always has a workspace","Remember non-TTY stdin auto-declines the prompt; don't rely on the default 'yes'"],"tags":["fmt","cli","interactive-prompt","workspace","non-tty"],"backgroundTag":"non-interactive-confirmation-failed","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}