moonD4rk/HackBrowserData · error

create temp dir: %w

Error message

create temp dir: %w

What it means

NewSession wraps os.MkdirTemp failures with "create temp dir: %w". Every extraction run starts by creating a unique temporary directory (prefix "hbd-" under os.TempDir()) to stage copied browser files. If the OS refuses to create that directory, the session cannot start and no browser data can be extracted.

Source

Thrown at filemanager/session.go:21

import (
	"errors"
	"fmt"
	"os"
	"runtime"
)

// Session manages temporary files for a single browser extraction run.
// It creates an isolated temp directory and provides methods to copy
// browser files into it. Call Cleanup() when done to remove all temp files.
type Session struct {
	tempDir string
}

// NewSession creates a session with a unique temporary directory.
func NewSession() (*Session, error) {
	dir, err := os.MkdirTemp("", "hbd-*")
	if err != nil {
		return nil, fmt.Errorf("create temp dir: %w", err)
	}
	return &Session{tempDir: dir}, nil
}

// TempDir returns the session's temporary directory path.
func (s *Session) TempDir() string {
	return s.tempDir
}

// Acquire copies a browser file (or directory) from src to dst.
// For regular files, it also copies SQLite WAL and SHM companion files
// if they exist. For directories (e.g. LevelDB), it copies the entire
// directory while skipping lock files.
//
// On Windows, if the normal copy fails (e.g. file locked by Chrome),
// it falls back to DuplicateHandle + FileMapping to bypass exclusive locks.
func (s *Session) Acquire(src, dst string, isDir bool) error {
	if isDir {

View on GitHub (pinned to 0503d04d7a)

Solutions

  1. Check and fix the temp environment variables (TMP/TEMP/TMPDIR) so they point to an existing, writable directory.
  2. Free disk space on the volume holding the temp directory.
  3. Run the tool under a user account with write permission on the temp directory.
  4. As a last resort, set TMPDIR to a manually created writable directory before launching (e.g. TMPDIR=/var/tmp/hbd hbd ...).

Example fix

// before
session, err := filemanager.NewSession()
if err != nil {
    return err
}
// after
if err := os.MkdirAll(os.TempDir(), 0o700); err != nil {
    return fmt.Errorf("temp dir unavailable: %w", err)
}
session, err := filemanager.NewSession()
if err != nil {
    return fmt.Errorf("session setup: %w", err)
}
Defensive patterns

Strategy: validation

Validate before calling

// verify temp location is writable before calling NewSession
probe := filepath.Join(os.TempDir(), ".hbd-probe")
if err := os.WriteFile(probe, nil, 0o600); err != nil {
    return fmt.Errorf("temp dir %s not writable: %w", os.TempDir(), err)
}
os.Remove(probe)
session, err := filemanager.NewSession()

Try / catch

// Go
session, err := filemanager.NewSession()
if err != nil {
    return fmt.Errorf("cannot create session (check TMP/TEMP/TMPDIR and disk space): %w", err)
}

Prevention

When it happens

Trigger: Calling filemanager.NewSession() when the temp directory (TMP/TEMP on Windows, /tmp on Unix) does not exist, is not writable, is full, or when the environment TMPDIR/TMP/TEMP points to an invalid path.

Common situations: Running in restricted sandboxes/containers with read-only /tmp; TMPDIR pointing at a deleted or non-existent directory; disk quota exhausted; Windows services running under accounts without a writable %TEMP%; temp cleaner processes racing the tool.

Understand the failure class

Background: mkdir permission denied (EACCES): failed to create directory errors explained — this error's family across 32 libraries.

Related errors


AI-assisted analysis of moonD4rk/HackBrowserData@0503d04d7a (2026-09-06). Data as JSON: /api/errors/c39de3e8aaa03f42. Report an issue: GitHub.