chenhg5/cc-connect · error

work_dir is not a directory: %s

Error message

work_dir is not a directory: %s

What it means

validateProjectWorkDir throws this when the path exists (os.Stat succeeds) but is a regular file (or other non-directory) rather than a directory. Agents need a working directory, so a file path is rejected.

Source

Thrown at core/setup.go:526

		"restart_required": true,
	})
}

func validateProjectWorkDir(workDir string) (string, error) {
	trimmed := strings.TrimSpace(workDir)
	if trimmed == "" {
		return "", nil
	}

	info, err := os.Stat(trimmed)
	if err != nil {
		if os.IsNotExist(err) {
			return "", fmt.Errorf("work_dir does not exist: %s", trimmed)
		}
		return "", fmt.Errorf("work_dir is not accessible: %s: %w", trimmed, err)
	}
	if !info.IsDir() {
		return "", fmt.Errorf("work_dir is not a directory: %s", trimmed)
	}
	return trimmed, nil
}

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Change work_dir to the containing directory of the intended path
  2. Verify with `test -d <path> && echo dir` or `ls -ld <path>` before saving
  3. If a symlink is involved, confirm it resolves to a directory (readlink -f)

Example fix

// before
work_dir = "/home/alice/app/docker-compose.yml"
// after
work_dir = "/home/alice/app"
Defensive patterns

Strategy: validation

Validate before calling

wd := strings.TrimSpace(cfg.WorkDir)
info, err := os.Stat(wd)
switch {
case err != nil:
    return fmt.Errorf("stat %s: %w", wd, err)
case !info.IsDir():
    return fmt.Errorf("%s is a file; use its parent directory", wd)
}

Type guard

func isDir(path string) bool {
    info, err := os.Stat(path)
    return err == nil && info.IsDir()
}

Try / catch

dir, err := validateProjectWorkDir(cfg.WorkDir)
if err != nil {
    if strings.Contains(err.Error(), "not a directory") {
        dir = filepath.Dir(strings.TrimSpace(cfg.WorkDir))
        slog.Warn("work_dir was a file; using parent", "dir", dir)
    } else { return err }
}

Prevention

When it happens

Trigger: Pointing work_dir at a file such as config.toml, a binary, a symlink to a file, or accidentally pasting a file path into the project setup form (handleProjectDetail, handleProjectAddPlatform, setup save handlers).

Common situations: Copy-pasting a file path instead of the folder; tab-completion stopping one component short; macOS paths like /Users/me/project/file vs the project dir; work_dir accidentally set to the config file itself.

Related errors


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