{"record":{"id":"e1c90e243e1e4b96","repo":"charmbracelet/crush","slug":"failed-to-load-configuration-v","errorCode":null,"errorMessage":"failed to load configuration: %v","messagePattern":"failed to load configuration: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmd/logs.go","lineNumber":56,"sourceCode":"\t\tfollow, err := cmd.Flags().GetBool(\"follow\")\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to get follow flag: %v\", err)\n\t\t}\n\n\t\ttailLines, err := cmd.Flags().GetInt(\"tail\")\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to get tail flag: %v\", err)\n\t\t}\n\n\t\tlog.SetLevel(log.DebugLevel)\n\t\tlog.SetOutput(os.Stdout)\n\t\tif !term.IsTerminal(os.Stdout.Fd()) {\n\t\t\tlog.SetColorProfile(colorprofile.NoTTY)\n\t\t}\n\n\t\tcfg, err := config.Load(cwd, dataDir, false)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to load configuration: %v\", err)\n\t\t}\n\t\tlogsFile := filepath.Join(cfg.Config().Options.DataDirectory, \"logs\", \"crush.log\")\n\t\t_, err = os.Stat(logsFile)\n\t\tif os.IsNotExist(err) {\n\t\t\tlog.Warn(\"Looks like you are not in a crush project. No logs found.\")\n\t\t\treturn nil\n\t\t}\n\n\t\tif follow {\n\t\t\treturn followLogs(cmd.Context(), logsFile, tailLines)\n\t\t}\n\n\t\treturn showLogs(logsFile, tailLines)\n\t},\n}\n\nfunc init() {\n\tlogsCmd.Flags().BoolP(\"follow\", \"f\", false, \"Follow log output\")","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/charmbracelet/crush/blob/7944b8e52225d8805e31eacbf7ef24856b0dfb7a/internal/cmd/logs.go#L38-L74","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before: invalid JSON config\ncfg, err := config.Load(cwd, dataDir, false) // fails: unexpected token\n// after: fix crush.json\n{\n  \"provider\": { \"anthropic\": { ... } }\n} // valid JSON, no trailing commas\n","handlingStrategy":"validation","validationCode":"// Go: validate config before running the command\nif _, err := os.Stat(filepath.Join(cwd, \"crush.json\")); err == nil {\n    if _, jerr := os.ReadFile(filepath.Join(cwd, \"crush.json\")); jerr != nil {\n        return fmt.Errorf(\"config unreadable: %w\", jerr)\n    }\n    // also validate JSON parses\n}","typeGuard":null,"tryCatchPattern":"cfg, err := config.Load(cwd, dataDir, false)\nif err != nil {\n    return fmt.Errorf(\"failed to load configuration: %w\", err) // keep %w to inspect cause\n}","preventionTips":["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."],"tags":["config","cli","validation"],"backgroundTag":"config-load-failed","analyzedSha":"7944b8e52225d8805e31eacbf7ef24856b0dfb7a","analyzedAt":"2026-08-29T12:48:59.079Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}