plandex-ai/plandex · error

error creating temp dir: %v

Error message

error creating temp dir: %v

What it means

GetPlanDiffs fails when os.MkdirTemp cannot create a temp directory under the org's data dir while preparing to diff plan versions. Indicates the org directory is missing, unwritable, or the filesystem is out of space/inodes.

Source

Thrown at app/server/db/diff_helpers.go:29

	shared "plandex-shared"
)

func GetPlanDiffs(orgId, planId string, plain bool) (string, error) {
	planState, err := GetCurrentPlanState(CurrentPlanStateParams{
		OrgId:  orgId,
		PlanId: planId,
	})

	if err != nil {
		return "", fmt.Errorf("error getting current plan state: %v", err)
	}

	// create temp directory
	tempDirPath, err := os.MkdirTemp(getOrgDir(orgId), "tmp-diffs-*")

	if err != nil {
		return "", fmt.Errorf("error creating temp dir: %v", err)
	}

	defer func() {
		go os.RemoveAll(tempDirPath)
	}()

	// init a git repo in the temp dir
	err = initGitRepo(tempDirPath)

	if err != nil {
		return "", fmt.Errorf("error initializing git repo: %v", err)
	}

	files := planState.CurrentPlanFiles.Files
	removed := planState.CurrentPlanFiles.Removed

	// write the original files to the temp dir
	errCh := make(chan error, len(planState.ContextsByPath))

View on GitHub (pinned to e2d772072e)

Solutions

  1. Check the wrapped %v error (ENOENT, EACCES, ENOSPC) to identify the filesystem cause
  2. Ensure getOrgDir(orgId) exists — create it with os.MkdirAll before MkdirTemp
  3. Verify the process has write permission on the org directory and the volume is writable
  4. Free disk space if ENOSPC; mount a writable volume in containerized deployments

Example fix

// before
tempDirPath, err := os.MkdirTemp(getOrgDir(orgId), "tmp-diffs-*")
// after
orgDir := getOrgDir(orgId)
if err := os.MkdirAll(orgDir, 0o755); err != nil {
    return "", fmt.Errorf("error creating org dir: %v", err)
}
tempDirPath, err := os.MkdirTemp(orgDir, "tmp-diffs-*")
Defensive patterns

Strategy: validation

Validate before calling

orgDir := getOrgDir(orgId)
if info, err := os.Stat(orgDir); err != nil || !info.IsDir() {
    if mkErr := os.MkdirAll(orgDir, 0o755); mkErr != nil {
        return fmt.Errorf("org dir not writable: %v", mkErr)
    }
}

Try / catch

diff, err := db.GetPlanDiffs(orgId, planId, files)
if err != nil && strings.Contains(err.Error(), "error creating temp dir") {
    log.Printf("filesystem problem for org %s: %v — check disk/permissions", orgId, err)
    return err
}

Prevention

When it happens

Trigger: os.MkdirTemp(getOrgDir(orgId), "tmp-diffs-*") fails because the org directory doesn't exist, the filesystem is full or read-only, or permission bits prevent creation.

Common situations: Container images without a writable temp/data volume; org directory never initialized before the first diff; disk-full on the host; running with a restricted user lacking write access to the org dir.

Related errors


AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05). Data as JSON: /api/errors/f466c7c31dc49254. Report an issue: GitHub.