chenhg5/cc-connect · error

work_dir does not exist: %s

Error message

work_dir does not exist: %s

What it means

validateProjectWorkDir rejects a configured project work_dir when os.Stat reports the path does not exist. Configuration is validated eagerly so project agents never start in a missing directory; the trimmed path is echoed back in the error.

Source

Thrown at core/setup.go:521

		mgmtError(w, http.StatusInternalServerError, "save config: "+err.Error())
		return
	}
	mgmtJSON(w, http.StatusCreated, map[string]any{
		"message":          fmt.Sprintf("platform %q added to project %q", req.Type, projectName),
		"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. Create the directory: mkdir -p <path>, or correct the path in the project config
  2. Use an absolute path to avoid ambiguity about the process working directory
  3. If the directory lives in a container/volume, verify the mount exists on the host running cc-connect

Example fix

// before
work_dir = "~/projects/app"
// after
work_dir = "/home/alice/projects/app"  # must exist: mkdir -p /home/alice/projects/app
Defensive patterns

Strategy: validation

Validate before calling

wd := strings.TrimSpace(cfg.WorkDir)
if wd == "" { return errors.New("work_dir is required") }
abs, err := filepath.Abs(wd)
if err != nil { return err }
if info, err := os.Stat(abs); err != nil {
    return fmt.Errorf("work_dir missing: %s: %w", abs, err)
} else if !info.IsDir() {
    return fmt.Errorf("work_dir is not a directory: %s", abs)
}

Try / catch

dir, err := validateProjectWorkDir(cfg.WorkDir)
if err != nil {
    if strings.HasPrefix(err.Error(), "work_dir does not exist") {
        if mkErr := os.MkdirAll(strings.TrimSpace(cfg.WorkDir), 0o755); mkErr == nil {
            dir, err = validateProjectWorkDir(cfg.WorkDir)
        }
    }
    if err != nil { slog.Error("invalid work_dir", "err", err) }
}

Prevention

When it happens

Trigger: Saving a project (handleProjectDetail, handleSetupFeishuSave, handleSetupWeixinSave, handleProjectAddPlatform) with a work_dir pointing to a path that was deleted, never created, or mistyped.

Common situations: Typos in config.toml or the web setup form; directory removed after initial configuration; relative paths resolved against an unexpected working directory; Docker/volume mounts not present on the host.

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/c924b6b7c86b2ce5. Report an issue: GitHub.