owasp-amass/amass · error

mkdir failed for %s: %v

Error message

mkdir failed for %s: %v

What it means

CreateOutputDirectory resolves the output directory path via config.OutputDirectory and creates it (and any missing parents) with os.MkdirAll. This error wraps any failure from MkdirAll, meaning the directory could not be created at the requested path.

Source

Thrown at internal/tools/file.go:26

	"errors"
	"fmt"
	"io"
	"os"
	"path/filepath"

	"github.com/owasp-amass/amass/v5/config"
	"github.com/owasp-amass/amass/v5/resources"
)

func CreateOutputDirectory(dirpath string) error {
	// Prepare output file paths
	dir := config.OutputDirectory(dirpath)
	if dir == "" {
		return errors.New("failed to obtain the path for the output directory")
	}
	// If the directory does not yet exist, create it
	if err := os.MkdirAll(dir, 0755); err != nil {
		return fmt.Errorf("mkdir failed for %s: %v", dir, err)
	}
	// ensure that the permissions are set correctly
	if err := os.Chmod(dir, 0755); err != nil {
		return fmt.Errorf("failed to set permissions to 0755 for %s: %v", dir, err)
	}
	return nil
}

func CreateDefaultConfigFiles(dirpath string) error {
	for _, filename := range resources.DefaultFilesList {
		filepath := filepath.Join(dirpath, filename)
		if _, err := os.Stat(filepath); !os.IsNotExist(err) {
			// If the file already exists, skip creating it
			continue
		}

		file, err := resources.GetResourceFile(filename)
		if err != nil {

View on GitHub (pinned to 79299dce87)

Solutions

  1. Check that every component of the resolved path exists and is a directory; remove or rename any file that occupies the path
  2. Run with sufficient privileges or choose a writable output directory (e.g. $HOME/amass-output)
  3. Check free disk space (df -h) and filesystem mount status (mount | grep ro)
  4. Print the resolved dir and verify it manually with mkdir -p before retrying

Example fix

// before
if err := os.MkdirAll("/usr/local/amass/output", 0755); err != nil { ... }
// after
outDir := filepath.Join(os.Getenv("HOME"), "amass-output")
if err := os.MkdirAll(outDir, 0755); err != nil { ... }
Defensive patterns

Strategy: validation

When it happens

Trigger: Calling CreateOutputDirectory when a path component of dir is not a directory, the filesystem is read-only, the process lacks write permission on a parent, the disk is full, or dir is invalid (e.g. empty path components, too-long path).

Common situations: Running the CLI in a container with a read-only rootfs, pointing the output directory at /usr or another protected location without sudo, OUTPUT_DIR pointing into a file rather than a directory, or NFS/EFS mounts with permission restrictions.

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 owasp-amass/amass@79299dce87 (2026-09-06). Data as JSON: /api/errors/10604c9e8a335e58. Report an issue: GitHub.