chenhg5/cc-connect · error

iflowSession: resolve session dir: %w

Error message

iflowSession: resolve session dir: %w

What it means

Send wraps a failure from iflowSessionDir, which locates the directory where the iflow CLI stores its session data for this working directory. If the directory cannot be resolved (missing/unreadable paths, unexpected layout), Send aborts the turn and releases the busy flag.

Source

Thrown at agent/iflow/session.go:158

		mode:           s.mode,
		pendingTimeout: s.pendingToolTimeout(),
		processDone:    make(chan struct{}),
		pendingToolIDs: make(map[string]struct{}),
		pendingTools:   make(map[string]iflowToolUse),
		seenToolIDs:    make(map[string]struct{}),
		doneToolIDs:    make(map[string]struct{}),
	}

	defer func() {
		if !s.turnActive.Load() {
			turnCancel()
		}
	}()

	sessionDir, err := iflowSessionDir(s.workDir)
	if err != nil {
		s.turnActive.Store(false)
		return fmt.Errorf("iflowSession: resolve session dir: %w", err)
	}
	turn.sessionDir = sessionDir

	args := append([]string{}, s.extraArgs...)
	if s.model != "" {
		args = append(args, "-m", s.model)
	}

	switch s.mode {
	case "yolo":
		args = append(args, "--yolo")
	case "plan":
		args = append(args, "--plan")
	case "auto-edit":
		args = append(args, "--autoEdit")
	default:
		args = append(args, "--default")
	}

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Verify workDir exists and is writable by the cc-connect process
  2. Run the iflow CLI once manually in workDir to initialize its session directory
  3. Check HOME/env of the daemon (systemd/launchd often have a different HOME); set it explicitly
  4. Fix filesystem permissions on the iflow session directory path

Example fix

// before
workDir = "/home/app/projects" // path never used by iflow
// after
if err := os.MkdirAll(workDir, 0o755); err != nil { log.Fatal(err) }
// ensure the iflow CLI was run once in workDir before starting sessions
Defensive patterns

Strategy: validation

Validate before calling

if st, err := os.Stat(workDir); err != nil || !st.IsDir() {
    return fmt.Errorf("workDir invalid: %s", workDir)
}

Try / catch

if err := session.Send(ctx, msg, nil); err != nil {
    var wrapped error
    if errors.As(err, &wrapped) && strings.Contains(err.Error(), "resolve session dir") {
        log.Printf("fix iflow session dir for workDir; cause: %v", wrapped)
    }
}

Prevention

When it happens

Trigger: Calling Send() when iflowSessionDir(s.workDir) fails — typically because the iflow CLI has never run in that workDir so no session dir exists yet, the path is unreadable due to permissions, or a symlink/home-dir lookup failed.

Common situations: workDir misconfigured in config.toml (nonexistent or wrong path); iflow CLI never initialized in the container/home; running under a different user with no access to ~/.iflow; HOME unset in daemonized environment.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06). Data as JSON: /api/errors/86b27ef0937c6978. Report an issue: GitHub.