{"record":{"id":"ded367599e7adf80","repo":"denoland/deno","slug":"failed-to-run-native-tsc-e","errorCode":null,"errorMessage":"failed to run native tsc: {e}","messagePattern":"failed to run native tsc: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"cli/tsc/native.rs","lineNumber":234,"sourceCode":"    .arg(\"--project\")\n    .arg(tsconfig_path)\n    .arg(\"--noEmit\")\n    .arg(\"--pretty\")\n    .arg(\"false\")\n    .arg(\"--diagnostics\")\n    .current_dir(project_root)\n    // The native compiler is written in Go, whose `os.Getwd` trusts the `PWD`\n    // environment variable over `getcwd()`. `current_dir` calls `chdir` but\n    // does not update the inherited `PWD`, so a symlinked launch directory\n    // (e.g. `/tmp` -> `/private/tmp` on macOS) would leave `PWD` pointing at\n    // the symlink and make tsc report every path relative to it. Pin `PWD` to\n    // the same directory we chdir'd into.\n    .env(\"PWD\", project_root)\n    .stdout(Stdio::piped())\n    .stderr(Stdio::piped())\n    .output()\n    .await\n    .map_err(|e| anyhow::anyhow!(\"failed to run native tsc: {e}\"))\n}\n\n/// A single `path(line,col): error TS####: message` line from `tsc --pretty\n/// false`. Continuation lines (indented elaborations) are folded into the\n/// preceding diagnostic's message.\nstatic DIAGNOSTIC_RE: LazyLock<Regex> = LazyLock::new(|| {\n  Regex::new(\n    r\"^(?P<file>.+?)\\((?P<line>\\d+),(?P<col>\\d+)\\): (?P<cat>error|warning|message) TS(?P<code>\\d+): (?P<msg>.*)$\",\n  )\n  .unwrap()\n});\n\n/// The position-less form (`error TS####: message`), e.g. `TS18003` (no\n/// inputs) or a `TS5###` config error.\nstatic DIAGNOSTIC_NO_POS_RE: LazyLock<Regex> = LazyLock::new(|| {\n  Regex::new(r\"^(?P<cat>error|warning|message) TS(?P<code>\\d+): (?P<msg>.*)$\")\n    .unwrap()\n});","sourceCodeStart":216,"sourceCodeEnd":252,"githubUrl":"https://github.com/denoland/deno/blob/89f33cbef296a2b287f323d42de54c871fa69c77/cli/tsc/native.rs#L216-L252","documentation":"After obtaining the native compiler, deno spawns it with cwd set to the project root and PWD pinned to the same directory. If the OS-level spawn itself fails — executable missing, not executable, or a fork/exec error — the io error is wrapped in this message.","triggerScenarios":"The tsc path exists in the cache but is not executable (lost +x bit, extracted from a zip), the file vanished between the existence check and spawn, or process creation fails (memory limits, container restrictions).","commonSituations":"Cache corruption; extracting the toolchain without preserving permissions; DENO_DIR on a noexec mount; tightly limited containers.","solutions":["Delete the cached compiler directory ($DENO_DIR/tsc/<version>/<platform>) so the next run re-downloads and re-extracts it with correct permissions","Check the binary is executable and DENO_DIR is not mounted noexec: `ls -l <tsc-path>` and inspect mount options","Set DENO_TSC_BIN to a known-good tsc binary to bypass the cached copy"],"exampleFix":"# before: cached copy lost its exec bit\nls -l \"$DENO_DIR/tsc/7.0.2/linux-x64/lib/tsc\"   # missing x\n# after\nrm -rf \"$DENO_DIR/tsc/7.0.2\"\ndeno check mod.ts   # triggers a clean re-download","handlingStrategy":"retry","validationCode":"# bash: verify the cached binary is executable before running deno\ntscbin=\"$DENO_DIR/tsc/7.0.2/$(case \"$(uname -s)\" in Linux) echo linux;; Darwin) echo darwin;; *) echo win32;; esac)-$(uname -m | sed 's/x86_64/x64/;s/aarch64/arm64/')/lib/tsc\"\nif [ -e \"$tscbin\" ] && [ ! -x \"$tscbin\" ]; then rm -rf \"$(dirname \"$(dirname \"$tscbin\")\")\"; fi","typeGuard":null,"tryCatchPattern":"# bash: clear the cache and retry once on spawn failure\nif ! deno check mod.ts 2>err.log; then\n  grep -q \"failed to run native tsc\" err.log && rm -rf \"$DENO_DIR/tsc\" && exec deno check mod.ts\n  exit 1\nfi","preventionTips":["Never copy $DENO_DIR between machines without preserving exec bits","Avoid mounting DENO_DIR noexec; check with `mount | grep $(dirname $DENO_DIR)`","On spawn failures, deleting $DENO_DIR/tsc/<version> and retrying re-downloads cleanly"],"tags":["tsc","process","spawn","cache"],"backgroundTag":null,"analyzedSha":"89f33cbef296a2b287f323d42de54c871fa69c77","analyzedAt":"2026-08-16T07:54:21.310Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}