{"record":{"id":"5fc9dc75cbeb19f6","repo":"denoland/deno","slug":"failed-to-read-from-stdin","errorCode":null,"errorMessage":"Failed to read from stdin","messagePattern":"Failed to read from stdin","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/tools/lint/mod.rs","lineNumber":613,"sourceCode":") -> Result<bool, AnyError> {\n  let start_dir = &cli_options.start_dir;\n  let reporter_lock = Arc::new(Mutex::new(create_reporter(\n    workspace_lint_options.reporter_kind,\n  )));\n  let lint_config = start_dir\n    .to_lint_config(FilePatterns::new_with_base(start_dir.dir_path()))?;\n  let deno_lint_config =\n    resolve_lint_config(compiler_options_resolver, start_dir.dir_url())?;\n  let lint_options = LintOptions::resolve(lint_config, &lint_flags)?;\n  let configured_rules = lint_rule_provider\n    .resolve_lint_rules_err_empty(lint_options.rules, Some(start_dir))?;\n  let mut file_path = cli_options.initial_cwd().join(STDIN_FILE_NAME);\n  if let Some(ext) = cli_options.ext_flag() {\n    file_path.set_extension(ext);\n  }\n  let mut source_code = String::new();\n  if stdin().read_to_string(&mut source_code).is_err() {\n    return Err(anyhow!(\"Failed to read from stdin\"));\n  }\n\n  let linter = CliLinter::new(CliLinterOptions {\n    fix: false,\n    configured_rules,\n    deno_lint_config,\n    maybe_plugin_runner: None,\n  });\n\n  let r = linter.lint_file(&file_path, deno_ast::strip_bom(source_code), None);\n\n  let success =\n    handle_lint_result(&file_path.to_string_lossy(), r, reporter_lock.clone());\n  reporter_lock.lock().close(1);\n  Ok(success)\n}\n\nfn handle_lint_result(","sourceCodeStart":595,"sourceCodeEnd":631,"githubUrl":"https://github.com/denoland/deno/blob/89f33cbef296a2b287f323d42de54c871fa69c77/cli/tools/lint/mod.rs#L595-L631","documentation":"When linting from stdin, Deno reads all of standard input into a String via read_to_string. Any read failure — most commonly non-UTF-8 bytes in the stream — aborts with this message before linting begins.","triggerScenarios":"Piping binary or non-UTF-8-encoded content into `deno lint -` (e.g. cat icon.png | deno lint -), a broken/closed pipe mid-read, or a source file in UTF-16/latin-1 encoding.","commonSituations":"Windows-created files saved as UTF-16; accidentally concatenating a binary file into the lint stream; tooling that closes stdin early.","solutions":["Confirm the input is UTF-8 text (file src.ts or iconv probe)","Convert before piping: iconv -f UTF-16 -t UTF-8 src.ts | deno lint -","Pass file paths to deno lint instead of concatenating many files through stdin","Note: BOMs are handled (strip_bom); only encoding/IO breakage triggers this"],"exampleFix":"# before (src.ts is UTF-16)\ncat src.ts | deno lint -\n# after\niconv -f UTF-16 -t UTF-8 src.ts | deno lint -","handlingStrategy":"validation","validationCode":"# bail on non-UTF-8 before invoking deno\nif ! iconv -f UTF-8 -t UTF-8 src.ts >/dev/null 2>&1; then\n  echo \"src.ts is not valid UTF-8\" >&2\n  exit 2\nfi\ncat src.ts | deno lint -","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Standardize on UTF-8 in editor settings and .editorconfig","Pipe only single known-text files to stdin lint, never concatenated lists"],"tags":["lint","stdin","utf-8","encoding"],"backgroundTag":null,"analyzedSha":"89f33cbef296a2b287f323d42de54c871fa69c77","analyzedAt":"2026-08-16T07:54:21.310Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}