charmbracelet/crush · error
failed to create app workspace: %w
Error message
failed to create app workspace: %w
What it means
Once DB and config are ready, CreateWorkspace assembles the full app workspace via app.New(ctx, conn, cfg, skillsMgr). Any failure wiring services (agents, LSP, permissions, skills) is wrapped with this message and the workspace is not registered.
Source
Thrown at internal/backend/backend.go:445
if err != nil {
return nil, proto.Workspace{}, fmt.Errorf("failed to connect to database: %w", err)
}
// Discover skills once per workspace, before app.New. The backend
// hosts multiple workspaces concurrently, so the manager is
// constructed WITHOUT WithGlobalMirror to prevent last-writer-wins
// cross-talk between workspaces.
discoveryCfg := skillsDiscoveryConfig(cfg)
allSkills, activeSkills, skillStates := skills.DiscoverFromConfig(discoveryCfg)
skillsMgr := skills.NewManager(
allSkills, activeSkills, skillStates,
skills.WithResolvedPaths(discoveryCfg.ResolvePaths()),
skills.WithWorkingDir(discoveryCfg.WorkingDir),
)
appWorkspace, err := app.New(b.ctx, conn, cfg, skillsMgr)
if err != nil {
return nil, proto.Workspace{}, fmt.Errorf("failed to create app workspace: %w", err)
}
wsCtx, wsCancel := context.WithCancel(b.ctx)
ws := &Workspace{
App: appWorkspace,
ID: id,
Path: args.Path,
Cfg: cfg,
Env: args.Env,
Skills: skillsMgr,
resolvedPath: key,
ctx: wsCtx,
cancel: wsCancel,
clients: make(map[string]*clientState),
}
b.mu.Lock()
// Re-check admission: the client may have retired while the slowView on GitHub (pinned to 7944b8e522)
Solutions
- Inspect the wrapped inner error from app.New and fix that specific cause (agents, providers, migrations)
- Run interactively once to generate valid agent config
- Delete/reinitialize the workspace data directory if migrations are broken
Example fix
// before crush run # failed to create app workspace: coder agent configuration is missing // after # add agent coder block to crushrc, then crush run
Defensive patterns
Strategy: try-catch
Try / catch
ws, err := b.CreateWorkspace(ctx, args)
if err != nil && strings.Contains(err.Error(), "failed to create app workspace") {
return fmt.Errorf("workspace bootstrap failed: %w", err)
} Prevention
- Keep agent/provider config valid — test with a plain 'crush' launch after edits
- Don't hand-edit DB schema; rely on migrations
- Watch the wrapped inner error; fix the specific failing subsystem
When it happens
Trigger: app.New returns an error — e.g. agent configuration missing, provider resolution failure, skills manager setup error, or DB migration failure during app bootstrapping.
Common situations: Invalid agent/provider config that passes config.Init but fails at app wiring; broken skill directory setup; schema migration failure on an old database.
Related errors
- agent coordinator not initialized
- failed to initialize config: %w
- client not attached
- workspace closing
- requested channels differ from the existing workspace; chann
AI-assisted analysis of charmbracelet/crush@7944b8e522 (2026-08-29).
Data as JSON: /api/errors/2e481889d8babff0.
Report an issue: GitHub.