{"record":{"id":"2e481889d8babff0","repo":"charmbracelet/crush","slug":"failed-to-create-app-workspace-w","errorCode":null,"errorMessage":"failed to create app workspace: %w","messagePattern":"failed to create app workspace: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/backend/backend.go","lineNumber":445,"sourceCode":"\tif err != nil {\n\t\treturn nil, proto.Workspace{}, fmt.Errorf(\"failed to connect to database: %w\", err)\n\t}\n\n\t// Discover skills once per workspace, before app.New. The backend\n\t// hosts multiple workspaces concurrently, so the manager is\n\t// constructed WITHOUT WithGlobalMirror to prevent last-writer-wins\n\t// cross-talk between workspaces.\n\tdiscoveryCfg := skillsDiscoveryConfig(cfg)\n\tallSkills, activeSkills, skillStates := skills.DiscoverFromConfig(discoveryCfg)\n\tskillsMgr := skills.NewManager(\n\t\tallSkills, activeSkills, skillStates,\n\t\tskills.WithResolvedPaths(discoveryCfg.ResolvePaths()),\n\t\tskills.WithWorkingDir(discoveryCfg.WorkingDir),\n\t)\n\n\tappWorkspace, err := app.New(b.ctx, conn, cfg, skillsMgr)\n\tif err != nil {\n\t\treturn nil, proto.Workspace{}, fmt.Errorf(\"failed to create app workspace: %w\", err)\n\t}\n\n\twsCtx, wsCancel := context.WithCancel(b.ctx)\n\tws := &Workspace{\n\t\tApp:          appWorkspace,\n\t\tID:           id,\n\t\tPath:         args.Path,\n\t\tCfg:          cfg,\n\t\tEnv:          args.Env,\n\t\tSkills:       skillsMgr,\n\t\tresolvedPath: key,\n\t\tctx:          wsCtx,\n\t\tcancel:       wsCancel,\n\t\tclients:      make(map[string]*clientState),\n\t}\n\n\tb.mu.Lock()\n\t// Re-check admission: the client may have retired while the slow","sourceCodeStart":427,"sourceCodeEnd":463,"githubUrl":"https://github.com/charmbracelet/crush/blob/7944b8e52225d8805e31eacbf7ef24856b0dfb7a/internal/backend/backend.go#L427-L463","documentation":"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.","triggerScenarios":"app.New returns an error — e.g. agent configuration missing, provider resolution failure, skills manager setup error, or DB migration failure during app bootstrapping.","commonSituations":"Invalid agent/provider config that passes config.Init but fails at app wiring; broken skill directory setup; schema migration failure on an old database.","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"],"exampleFix":"// before\ncrush run  # failed to create app workspace: coder agent configuration is missing\n// after\n# add agent coder block to crushrc, then\ncrush run","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"ws, err := b.CreateWorkspace(ctx, args)\nif err != nil && strings.Contains(err.Error(), \"failed to create app workspace\") {\n    return fmt.Errorf(\"workspace bootstrap failed: %w\", err)\n}","preventionTips":["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"],"tags":["workspace","initialization","wiring"],"backgroundTag":"app-bootstrap-failed","analyzedSha":"7944b8e52225d8805e31eacbf7ef24856b0dfb7a","analyzedAt":"2026-08-29T12:48:59.079Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}