charmbracelet/crush · warning

no data available: no projects found

Error message

no data available: no projects found

What it means

runStats returns this hard-coded error when, after resolving projects (single dir, --crawl-dir, or --all), the projectStats slice is empty — i.e. no project databases were found at all. It is crush's own guard so the command reports a clear message instead of rendering empty statistics.

Source

Thrown at internal/cmd/stats.go:187

		event.StatsViewed()

		conn, err := db.Connect(ctx, dataDir)
		if err != nil {
			return fmt.Errorf("failed to connect to database: %w", err)
		}
		defer conn.Close()

		stats, err := gatherStats(ctx, conn)
		if err != nil {
			return fmt.Errorf("failed to gather stats: %w", err)
		}

		projectStats = []ProjectStats{{ProjectPath: "", Stats: stats}}
	}

	if len(projectStats) == 0 {
		return fmt.Errorf("no data available: no projects found")
	}

	// Merge stats from all projects.
	mergedStats := mergeStats(projectStats)

	if mergedStats.Total.TotalSessions == 0 {
		return fmt.Errorf("no data available: no sessions found in database")
	}

	currentUser, err := user.Current()
	if err != nil {
		return fmt.Errorf("failed to get current user: %w", err)
	}
	username := currentUser.Username

	var projName string
	switch {
	case crawlDir != "":

View on GitHub (pinned to 7944b8e522)

Solutions

  1. Run crush in a project at least once so sessions/projects are recorded, then retry stats.
  2. Verify the --crawl-dir path actually contains project data dirs with crush.db: find <dir> -name crush.db.
  3. Use `crush stats` without flags (default project) or `--all` if projects.json has entries.
  4. Check cwd: relative crawl paths resolve from where the command runs; pass an absolute path.

Example fix

// before
crush stats --crawl-dir ./nonexistent
// after
find ~/code -name crush.db 2>/dev/null   # confirm projects exist
crush stats --crawl-dir ~/code
Defensive patterns

Strategy: validation

Validate before calling

func hasProjects(root string) bool {
	found := false
	filepath.WalkDir(root, func(p string, d os.DirEntry, err error) error {
		if err == nil && d.Name() == "crush.db" {
			found = true
			return filepath.SkipAll
		}
		return nil
	})
	return found
}

Prevention

When it happens

Trigger: Running `crush stats --crawl-dir <dir>` over a directory containing no crush projects (no crush.db files anywhere below it); running `crush stats --all` when projects.json is empty or missing; running stats in a fresh project where no session was ever recorded so no project db exists.

Common situations: Pointing --crawl-dir at the wrong parent directory; using --all on a brand-new machine before ever running crush; projects.json lost after wiping the data dir; typos in the crawl path (relative path resolved from an unexpected cwd).

Related errors


AI-assisted analysis of charmbracelet/crush@7944b8e522 (2026-08-29). Data as JSON: /api/errors/2ba4c26c8d54aced. Report an issue: GitHub.