micro/go-micro · error
failed to load local profile: %v
Error message
failed to load local profile: %v
What it means
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.
Source
Thrown at cmd/cmd.go:385
return c.opts
}
func (c *cmd) Before(ctx *cli.Context) error {
// If flags are set then use them otherwise do nothing
var serverOpts []server.Option
var clientOpts []client.Option
// --- Profile Grouping Extension ---
profileName := ctx.String("profile")
if profileName == "" {
profileName = os.Getenv("MICRO_PROFILE")
}
if profileName != "" {
switch profileName {
case "local":
imported, ierr := mprofile.LocalProfile()
if ierr != nil {
return fmt.Errorf("failed to load local profile: %v", ierr)
}
*c.opts.Registry = imported.Registry
*c.opts.Broker = imported.Broker
*c.opts.Store = imported.Store
*c.opts.Transport = imported.Transport
default:
// Plugin-backed profiles (e.g. nats) register themselves from their
// own package — linked via go-micro.dev/v6/cmd/defaults or a direct
// import — so binaries that never select them do not carry them.
imported, ierr := mprofile.Load(profileName)
if ierr != nil {
return fmt.Errorf("failed to load %s profile: %v", profileName, ierr)
}
// Set the registry
sopts, clopts := c.setRegistry(imported.Registry)
serverOpts = append(serverOpts, sopts...)
clientOpts = append(clientOpts, clopts...)
View on GitHub (pinned to 24529f1404)
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.
Example fix
// before micro --profile local server // after (drop the profile or fix underlying cause) micro server // or inspect the wrapped error: // failed to load local profile: <inner cause>
Defensive patterns
Strategy: validation
Validate before calling
// before invoking with a profile, confirm the binary supports it
if len(os.Getenv("MICRO_PROFILE")) > 0 && os.Getenv("MICRO_PROFILE") != "local" {
log.Fatalf("profile %q may not be linked; use --profile local or rebuild", os.Getenv("MICRO_PROFILE"))
} Try / catch
if err := cmd.New().Run(); err != nil {
var perr error
if strings.Contains(err.Error(), "failed to load local profile:") {
perr = fmt.Errorf("local profile unavailable, falling back to defaults: %w", err)
log.Println(perr)
os.Exit(1)
}
log.Fatal(err)
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- failed to load %s profile: %v
- Cannot use two forms of the same flag: <name> <ff.Name>
- flags not parsed
- failed to start agent: %w
- store %q is not linked into this binary: import go-micro.dev
AI-assisted analysis of micro/go-micro@24529f1404 (2026-09-01).
Data as JSON: /api/errors/9aa28d37124d20b3.
Report an issue: GitHub.