charmbracelet/crush · error
failed to initialize config: %w
Error message
failed to initialize config: %w
What it means
After resolving the workspace key, CreateWorkspace initializes the config service via config.Init(path, dataDir, debug). Any error loading/validating crushrc or crush.json for that workspace is wrapped with this message.
Source
Thrown at internal/backend/backend.go:416
b.pending--
// If this create ended up registering nothing (it failed, or
// deduped onto an existing workspace that has since gone) and
// it was holding the last teardown back, the server may now be
// idle with no pending work. Arm the idle-shutdown timer here so
// a failed create racing the last teardown does not leak an
// empty server that a plain teardown already declined to reap.
shutdownNow := b.scheduleShutdownIfIdleLocked()
b.mu.Unlock()
if shutdownNow {
slog.Info("No workspaces remain after create settled, shutting down server...")
b.shutdownFn()
}
}()
id := uuid.New().String()
cfg, err := config.Init(args.Path, args.DataDir, args.Debug)
if err != nil {
return nil, proto.Workspace{}, fmt.Errorf("failed to initialize config: %w", err)
}
cfg.Overrides().SkipPermissionRequests = args.YOLO
cfg.Overrides().EnabledChannels = args.Channels
if err := createDotCrushDir(cfg.Config().Options.DataDirectory); err != nil {
return nil, proto.Workspace{}, fmt.Errorf("failed to create data directory: %w", err)
}
conn, err := db.Connect(b.ctx, cfg.Config().Options.DataDirectory, db.WithDataDirLock(true))
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.View on GitHub (pinned to 7944b8e522)
Solutions
- Run 'crush' interactively or validate the config to see the underlying wrapped error and fix it
- Fix syntax errors in crushrc / crush.json (deprecated but still parsed)
- Check file permissions on the config file and data directory
Example fix
// before (crushrc) provider anthropic model claude # unclosed block // after provider "anthropic" model "anthropic/claude-sonnet-4" end
Defensive patterns
Strategy: try-catch
Try / catch
ws, err := b.CreateWorkspace(ctx, args)
if err != nil {
var cfgErr = "failed to initialize config"
if strings.Contains(err.Error(), cfgErr) {
// surface underlying %w cause to user, e.g. run config validation
return fmt.Errorf("workspace config invalid: %w", err)
}
return err
} Prevention
- Validate crushrc/crush.json syntax before shipping config changes
- Keep config files readable by the user running crush
- Test config changes interactively before using non-interactive mode
When it happens
Trigger: config.Init fails because the workspace's crushrc/crush.json has a syntax error, fails schema validation, or cannot be read (permissions), or the data directory is unusable.
Common situations: Malformed crushrc bash syntax; invalid JSON in crush.json; unsupported/unknown keys after version upgrades; unreadable config file permissions.
Related errors
- agent coordinator not initialized
- failed to create app workspace: %w
- failed to initialize agent: %w
- config not loaded
- no workspace config path configured
AI-assisted analysis of charmbracelet/crush@7944b8e522 (2026-08-29).
Data as JSON: /api/errors/f8c9165c985cd8cf.
Report an issue: GitHub.