{"record":{"id":"9aa28d37124d20b3","repo":"micro/go-micro","slug":"failed-to-load-local-profile-v","errorCode":null,"errorMessage":"failed to load local profile: %v","messagePattern":"failed to load local profile: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/cmd.go","lineNumber":385,"sourceCode":"\treturn c.opts\n}\n\nfunc (c *cmd) Before(ctx *cli.Context) error {\n\t// If flags are set then use them otherwise do nothing\n\tvar serverOpts []server.Option\n\tvar clientOpts []client.Option\n\t// --- Profile Grouping Extension ---\n\n\tprofileName := ctx.String(\"profile\")\n\tif profileName == \"\" {\n\t\tprofileName = os.Getenv(\"MICRO_PROFILE\")\n\t}\n\tif profileName != \"\" {\n\t\tswitch profileName {\n\t\tcase \"local\":\n\t\t\timported, ierr := mprofile.LocalProfile()\n\t\t\tif ierr != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to load local profile: %v\", ierr)\n\t\t\t}\n\t\t\t*c.opts.Registry = imported.Registry\n\t\t\t*c.opts.Broker = imported.Broker\n\t\t\t*c.opts.Store = imported.Store\n\t\t\t*c.opts.Transport = imported.Transport\n\t\tdefault:\n\t\t\t// Plugin-backed profiles (e.g. nats) register themselves from their\n\t\t\t// own package — linked via go-micro.dev/v6/cmd/defaults or a direct\n\t\t\t// import — so binaries that never select them do not carry them.\n\t\t\timported, ierr := mprofile.Load(profileName)\n\t\t\tif ierr != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to load %s profile: %v\", profileName, ierr)\n\t\t\t}\n\t\t\t// Set the registry\n\t\t\tsopts, clopts := c.setRegistry(imported.Registry)\n\t\t\tserverOpts = append(serverOpts, sopts...)\n\t\t\tclientOpts = append(clientOpts, clopts...)\n","sourceCodeStart":367,"sourceCodeEnd":403,"githubUrl":"https://github.com/micro/go-micro/blob/24529f140421a11a33b6999ab7944f2021cfd69c/cmd/cmd.go#L367-L403","documentation":"micro (go-micro) CLI command setup tries to load the built-in \"local\" profile when --profile local is passed. mprofile.LocalProfile() constructs a full stack (registry, broker, store, transport) locally; if any component fails to build, the error is wrapped with this message and aborts the Before hook, so the command never runs.","triggerScenarios":"Running a micro CLI binary with --profile local (or a config that selects the local profile) when mprofile.LocalProfile() returns an error — e.g. one of the default components cannot be constructed or an underlying constructor fails.","commonSituations":"Misconfigured environment that the local profile depends on; a broken or incompatible default plugin build; running a stripped binary where a component the local profile expects is unavailable.","solutions":["Read the wrapped inner error (%v) — it names the component that failed to initialize; fix that component's configuration.","Drop --profile local (or pass a different profile) so the default option set is used instead.","Rebuild the binary with go-micro.dev/v6/cmd/defaults imported so all profile components are linked.","Check env vars consumed by the local profile (e.g. registry/broker addresses) and correct them."],"exampleFix":"// before\nmicro --profile local server\n// after (drop the profile or fix underlying cause)\nmicro server\n// or inspect the wrapped error:\n// failed to load local profile: <inner cause>","handlingStrategy":"validation","validationCode":"// before invoking with a profile, confirm the binary supports it\nif len(os.Getenv(\"MICRO_PROFILE\")) > 0 && os.Getenv(\"MICRO_PROFILE\") != \"local\" {\n    log.Fatalf(\"profile %q may not be linked; use --profile local or rebuild\", os.Getenv(\"MICRO_PROFILE\"))\n}","typeGuard":null,"tryCatchPattern":"if err := cmd.New().Run(); err != nil {\n    var perr error\n    if strings.Contains(err.Error(), \"failed to load local profile:\") {\n        perr = fmt.Errorf(\"local profile unavailable, falling back to defaults: %w\", err)\n        log.Println(perr)\n        os.Exit(1)\n    }\n    log.Fatal(err)\n}","preventionTips":["Inspect the wrapped inner error before changing config — it names the failing component.","Only pass --profile local when running a binary linked with cmd/defaults.","Test profile startup in CI so component failures surface before production."],"tags":["cli","profile","startup"],"backgroundTag":"profile-load-failed","analyzedSha":"24529f140421a11a33b6999ab7944f2021cfd69c","analyzedAt":"2026-09-01T02:52:24.923Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}