{"record":{"id":"00b521c6c3ac27c2","repo":"denoland/deno","slug":"node-shim-is-not-supported-on-this-platform","errorCode":null,"errorMessage":"node shim is not supported on this platform","messagePattern":"node shim is not supported on this platform","errorType":"exception","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"cli/node_compat_shim.rs","lineNumber":284,"sourceCode":"  // binary's bytes with no extra disk; fall back to a copy across volumes.\n  if shim_path.exists() {\n    let _ = std::fs::remove_file(shim_path);\n  }\n  match std::fs::hard_link(current_exe, shim_path) {\n    Ok(()) => Ok(()),\n    Err(_) => {\n      // Copy via a unique temp file then atomically rename into place.\n      let tmp_path =\n        shim_path.with_extension(format!(\"exe.tmp-{}\", std::process::id()));\n      std::fs::copy(current_exe, &tmp_path)?;\n      std::fs::rename(&tmp_path, shim_path)\n    }\n  }\n}\n\n#[cfg(not(any(unix, windows)))]\nfn create_shim(_shim_path: &Path, _current_exe: &Path) -> std::io::Result<()> {\n  Err(std::io::Error::new(\n    std::io::ErrorKind::Unsupported,\n    \"node shim is not supported on this platform\",\n  ))\n}\n\n/// Prepend `dir` to the process's own `PATH` (idempotently), so spawned\n/// children inherit it.\nfn prepend_self_path(dir: &Path) {\n  let sep = if cfg!(windows) { ';' } else { ':' };\n  let current = std::env::var_os(\"PATH\").unwrap_or_default();\n  // Idempotency: don't grow PATH if the dir is already present.\n  let already_present = std::env::split_paths(&current).any(|p| p == dir);\n  if already_present {\n    return;\n  }\n\n  let mut new_path = OsString::from(dir);\n  if !current.is_empty() {","sourceCodeStart":266,"sourceCodeEnd":302,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/node_compat_shim.rs#L266-L302","documentation":"The node-compat shim (the fake `node` executable Deno can install so child processes spawning `node` get routed back into the current Deno binary) is implemented with Unix hardlink/rename semantics and a Windows branch. This stub is compiled only for targets that are neither Unix nor Windows, and it unconditionally returns ErrorKind::Unsupported — the capability does not exist on such platforms.","triggerScenarios":"Building/running the Deno CLI for an exotic target (e.g. wasm32, fuchsia, redox) and triggering node-shim installation (the code path that would create the shim). On Linux/macOS/Windows builds the real implementations are compiled instead, so this error cannot occur there.","commonSituations":"Community ports of Deno to niche OSes; cross-compilation experiments; static analysis/tooling that enumerates all cfg branches. Not reachable in official x64/arm64 Linux, macOS, or Windows builds.","solutions":["Run on a supported platform (Linux, macOS, Windows) where the shim is implemented","If you maintain a port, implement create_shim for your platform (copy + rename strategy) behind the appropriate cfg","Avoid the node-shim feature on unsupported targets (don't enable the code path that installs it)"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Rust: check platform support before touching the shim\nfn node_shim_supported() -> bool {\n    cfg!(any(unix, windows))\n}\nif !node_shim_supported() { /* skip node-shim install, use explicit `deno` path */ }","typeGuard":null,"tryCatchPattern":"match create_node_shim(&shim_path, &current_exe) {\n    Err(e) if e.kind() == std::io::ErrorKind::Unsupported => {\n        // platform cannot host a node shim: fall back to spawning `deno` directly\n        spawn_deno_directly();\n    }\n    r => r?,\n}","preventionTips":["On non-Unix/non-Windows targets, don't enable code paths that install the node shim","Gate node-compat spawning behind a platform capability check in your CLI","For exotic platforms, route child processes to an explicit deno binary path instead"],"tags":["node-compat","platform-support","shim","unsupported-platform"],"backgroundTag":"unsupported-platform","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}