charmbracelet/crush · error
failed to load configuration: %v
Error message
failed to load configuration: %v
What it means
After resolving flags, `crush logs` calls config.Load(cwd, dataDir, false) to locate the project's data directory. Any failure loading/validating the configuration (malformed crush.json/crushrc, unreadable file, invalid provider definitions, bad data-dir path) is wrapped with this message, preserving the underlying cause with %v.
Source
Thrown at internal/cmd/logs.go:56
follow, err := cmd.Flags().GetBool("follow")
if err != nil {
return fmt.Errorf("failed to get follow flag: %v", err)
}
tailLines, err := cmd.Flags().GetInt("tail")
if err != nil {
return fmt.Errorf("failed to get tail flag: %v", err)
}
log.SetLevel(log.DebugLevel)
log.SetOutput(os.Stdout)
if !term.IsTerminal(os.Stdout.Fd()) {
log.SetColorProfile(colorprofile.NoTTY)
}
cfg, err := config.Load(cwd, dataDir, false)
if err != nil {
return fmt.Errorf("failed to load configuration: %v", err)
}
logsFile := filepath.Join(cfg.Config().Options.DataDirectory, "logs", "crush.log")
_, err = os.Stat(logsFile)
if os.IsNotExist(err) {
log.Warn("Looks like you are not in a crush project. No logs found.")
return nil
}
if follow {
return followLogs(cmd.Context(), logsFile, tailLines)
}
return showLogs(logsFile, tailLines)
},
}
func init() {
logsCmd.Flags().BoolP("follow", "f", false, "Follow log output")View on GitHub (pinned to 7944b8e522)
Solutions
- Read the wrapped cause: run `crush logs` and inspect the full %v output — it names the config file and parse/validation problem.
- Validate your crush.json (JSON syntax) or crushrc script for typos; move or rename it temporarily to test (`mv crush.json crush.json.bak`).
- Update deprecated config fields to the current schema (JSON is deprecated in favor of crushrc).
- Check file permissions on the config and the --data-dir path; pass an explicit --cwd/--data-dir pointing to a valid project.
Example fix
// before: invalid JSON config
cfg, err := config.Load(cwd, dataDir, false) // fails: unexpected token
// after: fix crush.json
{
"provider": { "anthropic": { ... } }
} // valid JSON, no trailing commas
Defensive patterns
Strategy: validation
Validate before calling
// Go: validate config before running the command
if _, err := os.Stat(filepath.Join(cwd, "crush.json")); err == nil {
if _, jerr := os.ReadFile(filepath.Join(cwd, "crush.json")); jerr != nil {
return fmt.Errorf("config unreadable: %w", jerr)
}
// also validate JSON parses
} Try / catch
cfg, err := config.Load(cwd, dataDir, false)
if err != nil {
return fmt.Errorf("failed to load configuration: %w", err) // keep %w to inspect cause
} Prevention
- Validate crush.json/crushrc with a JSON linter after hand edits.
- Migrate deprecated crush.json fields to crushrc on upgrades.
- Never reference providers/models that are not defined.
- Check file permissions on config and data directories.
When it happens
Trigger: Running `crush logs` in a directory containing an invalid or non-parseable crush.json/crushrc, a config referencing unknown providers or missing required fields, an unreadable config file (permissions), or an invalid --data-dir path.
Common situations: Hand-edited crush.json with JSON syntax errors; deprecated crush.json fields after an upgrade; config with a provider block referencing a missing model; running from a directory where the config file is not readable.
Related errors
- %s model %q not found
- failed to initialize config: %w
- not a valid bedrock api key
- not a valid vercel api key
- mcp stdio config requires a non-empty 'command' field
AI-assisted analysis of charmbracelet/crush@7944b8e522 (2026-08-29).
Data as JSON: /api/errors/e1c90e243e1e4b96.
Report an issue: GitHub.