owasp-amass/amass · error
failed to create the temp dir
Error message
failed to create the temp dir
What it means
After the output directory resolves, createTemporaryDir calls os.MkdirTemp(outdir, "session-"+id) to create the per-session directory; if that syscall fails, this error replaces the detailed OS error. It indicates the output directory exists as a path value but a temp directory could not be created inside it.
Source
Thrown at engine/sessions/session.go:280
}
// Initialize the database store
store, err := assetdb.New(s.dbtype, s.dsn)
if err != nil {
return errors.New("failed to initialize database store: " + err.Error())
}
s.db = store
return nil
}
func (s *Session) createTemporaryDir() (string, error) {
outdir := config.OutputDirectory()
if outdir == "" {
return "", errors.New("failed to obtain the output directory")
}
dir, err := os.MkdirTemp(outdir, "session-"+s.ID().String())
if err != nil {
return "", errors.New("failed to create the temp dir")
}
return dir, nil
}
func (s *Session) createSessionPipelines(reg et.Registry) error {
s.pipelines = make(et.SessionPipelines, len(oam.AssetList))
for _, atype := range oam.AssetList {
p, err := reg.BuildAssetPipeline(s.Ctx(), atype)
if err != nil {
return err
}
s.pipelines[atype] = p
}
return nil
}View on GitHub (pinned to 79299dce87)
Solutions
- Pre-create the output directory with correct permissions (os.MkdirAll(outdir, 0o755)) before session creation
- Check directory ownership/writability for the user running the process
- Confirm the output path is a directory, not a file, and on a writable (not read-only) filesystem
- Check disk space and inode availability on the volume
- Temporarily log the underlying os.MkdirTemp error to see the precise errno
Example fix
// before
outdir := config.OutputDirectory()
if _, err := os.Stat(outdir); err != nil { log.Fatal(err) }
// after
outdir := config.OutputDirectory()
if err := os.MkdirAll(outdir, 0o755); err != nil {
log.Fatalf("cannot create output dir %s: %v", outdir, err)
} Defensive patterns
Strategy: validation
Validate before calling
outdir := config.OutputDirectory()
if err := os.MkdirAll(outdir, 0o755); err != nil {
return fmt.Errorf("cannot prepare output dir %s: %w", outdir, err)
}
if fi, err := os.Stat(outdir); err != nil || !fi.IsDir() || unix.Access(outdir, unix.W_OK) != nil {
return fmt.Errorf("output dir %s is not writable", outdir)
} Try / catch
if err := session.CreateSession(cfg); err != nil {
if strings.Contains(err.Error(), "failed to create the temp dir") {
log.Fatalf("cannot create temp dir under %s: check permissions, disk space, and mount flags", config.OutputDirectory())
}
return err
} Prevention
- Create the output directory at service startup with os.MkdirAll and correct ownership
- Run the process as a user with write access to the output path
- Monitor disk space on the volume holding the output directory
- Avoid read-only container mounts on the output path
When it happens
Trigger: CreateSession -> createTemporaryDir when os.MkdirTemp fails: the output directory does not exist, is not writable, is actually a file, or the filesystem is full/read-only.
Common situations: Output directory configured but never created (app does not MkdirAll); permission denied after service user change; disk full on the volume; SELinux/container read-only mount on the output path; session ID producing an unusable prefix.
Understand the failure class
Background: mkdir permission denied (EACCES): failed to create directory errors explained — this error's family across 32 libraries.
Related errors
- failed to obtain the output directory
- unable to load the file in the alterations wordlist_file set
- mkdir failed for %s: %v
- failed to set permissions to 0755 for %s: %v
- failed to create the output file %s: %v
AI-assisted analysis of owasp-amass/amass@79299dce87 (2026-09-06).
Data as JSON: /api/errors/db32abfde883c150.
Report an issue: GitHub.