{"record":{"id":"258131d0805257f7","repo":"openimsdk/open-im-server","slug":"no-command-to-run","errorCode":null,"errorMessage":"no command to run","messagePattern":"no command to run","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/main.go","lineNumber":260,"sourceCode":"\t\t\"\", \"\",\n\t\tconf.RemainLogLevel,\n\t\tconf.IsStdout,\n\t\tconf.IsJson,\n\t\tconf.StorageLocation,\n\t\tconf.RemainRotationCount,\n\t\tconf.RotationTime,\n\t\tstrings.TrimSpace(version.Version),\n\t\tconf.IsSimplify,\n\t); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n\n}\n\nfunc (x *cmds) run(ctx context.Context) error {\n\tif len(x.cmds) == 0 {\n\t\treturn fmt.Errorf(\"no command to run\")\n\t}\n\tif err := x.initAllConfig(); err != nil {\n\t\treturn err\n\t}\n\tif err := x.initLog(); err != nil {\n\t\treturn err\n\t}\n\n\tctx, cancel := context.WithCancelCause(ctx)\n\n\tgo func() {\n\t\t<-ctx.Done()\n\t\tlog.ZError(ctx, \"context server exit cause\", context.Cause(ctx))\n\t}()\n\n\tif prometheus := x.config.API.Prometheus; prometheus.Enable {\n\t\tvar (\n\t\t\tport int","sourceCodeStart":242,"sourceCodeEnd":278,"githubUrl":"https://github.com/openimsdk/open-im-server/blob/175a7bb0673eca18e9d1b10bff4f728da6b1b513/cmd/main.go#L242-L278","documentation":"cmds.run validates that at least one subcommand was registered before doing any initialization. If x.cmds is empty there is nothing to execute, so it aborts immediately with this error. It is a startup-time guard, not a runtime fault.","triggerScenarios":"The binary is invoked without registering any command (e.g. cmd.Execute / cmd.AddCommand never added a runnable command, or the CLI args selected no command) so len(x.cmds)==0 when run() starts.","commonSituations":"Running the OpenIM server binary with no subcommand (e.g. just ./openim-server instead of ./openim-server --config=... start); a miswired main.go that forgot cmd.AddCommand; a wrapper script passing empty arguments.","solutions":["Invoke the binary with a valid subcommand/arguments so a command gets registered","Check main.go that cmd.AddCommand(...) (or the equivalent registration) is called for the intended commands","If embedding, call the command-registration API before run() executes"],"exampleFix":"// before\n./openim-server            # no command -> 'no command to run'\n// after\n./openim-server --config=config/ start","handlingStrategy":"validation","validationCode":"if len(os.Args) < 2 {\n\tfmt.Fprintln(os.Stderr, \"usage: openim-server <command> [flags]\")\n\tos.Exit(2)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always invoke the binary with an explicit subcommand","Verify command registration (AddCommand) after refactoring main.go","Add a usage/help message on empty invocation"],"tags":["cli","startup","configuration"],"backgroundTag":"missing-command-argument","analyzedSha":"175a7bb0673eca18e9d1b10bff4f728da6b1b513","analyzedAt":"2026-09-04T16:52:56.821Z","contentChangedAt":"2026-09-04T16:52:56.821Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}