{"record":{"id":"4a6d644629b21aa5","repo":"denoland/deno","slug":"is-not-a-directory","errorCode":null,"errorMessage":"'{}' is not a directory","messagePattern":"'(.+?)' is not a directory","errorType":"exception","errorClass":"AnyError","httpStatus":null,"severity":"error","filePath":"cli/util/temp.rs","lineNumber":153,"sourceCode":"        current_uid\n      );\n    }\n    let mode = metadata.mode();\n    if mode & 0o022 != 0 && mode & 0o1000 == 0 {\n      bail!(\n        \"temporary directory ancestor '{}' is writable by other users without the sticky bit\",\n        ancestor.display()\n      );\n    }\n  }\n  Ok(())\n}\n\n#[cfg(not(unix))]\nfn ensure_secure_temp_parent(path: &Path) -> Result<(), AnyError> {\n  let metadata = std::fs::symlink_metadata(path)?;\n  if metadata.file_type().is_symlink() || !metadata.is_dir() {\n    bail!(\"'{}' is not a directory\", path.display());\n  }\n  Ok(())\n}\n\n#[cfg(unix)]\nfn create_dir_secure(path: &Path) -> std::io::Result<()> {\n  use std::os::unix::fs::DirBuilderExt;\n\n  std::fs::DirBuilder::new().mode(0o700).create(path)\n}\n\n#[cfg(not(unix))]\nfn create_dir_secure(path: &Path) -> std::io::Result<()> {\n  std::fs::create_dir(path)\n}\n\n#[cfg(unix)]\nfn ensure_secure_temp_dir(path: &Path) -> Result<(), AnyError> {","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/util/temp.rs#L135-L171","documentation":"The non-Unix (Windows) version of `ensure_secure_temp_parent` validates the temp root with `symlink_metadata` and bails if the path is a symlink/reparse point or is not a real directory. Windows does not get the uid/mode ancestor walk Unix gets; this cheaper check still refuses symlinked temp roots so the temp path cannot be redirected out from under Deno.","triggerScenarios":"On Windows, TEMP/TMP (or TMPDIR) resolving to a symlink/junction to another location, or to a plain file — e.g. `mklink /J` junctions used to relocate TEMP to another drive, or a stale file left at the path.","commonSituations":"Windows machines redirecting %TEMP% via junction to save SSD space or sandbox browsers; CI images with symlinked temp; users setting TMP to a nonexistent or file path in scripts.","solutions":["Point TEMP/TMP at a real directory: `setx TEMP C:\\Users\\me\\AppData\\Local\\Temp` (no junction).","Remove the offending link/file: `rmdir <path>` for a junction, `del <path>` for a file.","If you need temp on another drive, create a plain directory there and set TEMP directly to it."],"exampleFix":"# before (PowerShell): TEMP is a junction\n(Get-Item $env:TEMP).LinkType    # Junction\ndeno install                      # error: '<path>' is not a directory\n\n# after\nNew-Item -ItemType Directory -Force D:\\tmp\nsetx TEMP D:\\tmp                  # real directory, not a link\ndeno install","handlingStrategy":"validation","validationCode":"# PowerShell: reject symlinked or non-directory TEMP before running deno\n$ti = Get-Item \"$env:TEMP\" -ErrorAction SilentlyContinue\nif ($null -eq $ti -or $ti.LinkType -or -not $ti.PSIsContainer) {\n  Write-Error \"TEMP is a symlink or not a directory: $env:TEMP\"\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set TEMP/TMP to a plain local directory, never a junction or symlink.","Check launch scripts and policies that redirect TEMP for sandboxing or disk-space reasons.","After moving temp, delete leftover links at the old path."],"tags":["security","temp-dir","windows","symlink"],"backgroundTag":"insecure-temp-directory","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}