denoland/deno · error · AnyError
'{}' is not a directory
Error message
'{}' is not a directory What it means
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.
Source
Thrown at cli/util/temp.rs:153
current_uid
);
}
let mode = metadata.mode();
if mode & 0o022 != 0 && mode & 0o1000 == 0 {
bail!(
"temporary directory ancestor '{}' is writable by other users without the sticky bit",
ancestor.display()
);
}
}
Ok(())
}
#[cfg(not(unix))]
fn ensure_secure_temp_parent(path: &Path) -> Result<(), AnyError> {
let metadata = std::fs::symlink_metadata(path)?;
if metadata.file_type().is_symlink() || !metadata.is_dir() {
bail!("'{}' is not a directory", path.display());
}
Ok(())
}
#[cfg(unix)]
fn create_dir_secure(path: &Path) -> std::io::Result<()> {
use std::os::unix::fs::DirBuilderExt;
std::fs::DirBuilder::new().mode(0o700).create(path)
}
#[cfg(not(unix))]
fn create_dir_secure(path: &Path) -> std::io::Result<()> {
std::fs::create_dir(path)
}
#[cfg(unix)]
fn ensure_secure_temp_dir(path: &Path) -> Result<(), AnyError> {View on GitHub (pinned to 9ad36f7a2c)
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.
Example fix
# before (PowerShell): TEMP is a junction (Get-Item $env:TEMP).LinkType # Junction deno install # error: '<path>' is not a directory # after New-Item -ItemType Directory -Force D:\tmp setx TEMP D:\tmp # real directory, not a link deno install
Defensive patterns
Strategy: validation
Validate before calling
# PowerShell: reject symlinked or non-directory TEMP before running deno
$ti = Get-Item "$env:TEMP" -ErrorAction SilentlyContinue
if ($null -eq $ti -or $ti.LinkType -or -not $ti.PSIsContainer) {
Write-Error "TEMP is a symlink or not a directory: $env:TEMP"
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Native addon cache path '{}' is not a private directory
- ERR_FS_INVALID_SYMLINK_TYPE
- temporary directory ancestor '{}' is owned by uid {}, not cu
- temporary directory ancestor '{}' is writable by other users
- '{}' is owned by uid {}, not current uid {}
AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20).
Data as JSON: /api/errors/4a6d644629b21aa5.
Report an issue: GitHub.