{"record":{"id":"ff7584dc363f42a6","repo":"sipeed/picoclaw","slug":"workspace-is-not-initialized","errorCode":null,"errorMessage":"workspace is not initialized","messagePattern":"workspace is not initialized","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/picoclaw/internal/skills/command.go","lineNumber":54,"sourceCode":"\t\t\td.skillsLoader = skills.NewSkillsLoader(d.workspace, globalSkillsDir, builtinSkillsDir)\n\n\t\t\treturn nil\n\t\t},\n\t\tRunE: func(cmd *cobra.Command, _ []string) error {\n\t\t\treturn cmd.Help()\n\t\t},\n\t}\n\n\tloaderFn := func() (*skills.SkillsLoader, error) {\n\t\tif d.skillsLoader == nil {\n\t\t\treturn nil, fmt.Errorf(\"skills loader is not initialized\")\n\t\t}\n\t\treturn d.skillsLoader, nil\n\t}\n\n\tworkspaceFn := func() (string, error) {\n\t\tif d.workspace == \"\" {\n\t\t\treturn \"\", fmt.Errorf(\"workspace is not initialized\")\n\t\t}\n\t\treturn d.workspace, nil\n\t}\n\n\tcmd.AddCommand(\n\t\tnewListCommand(loaderFn),\n\t\tnewInstallCommand(),\n\t\tnewInstallBuiltinCommand(workspaceFn),\n\t\tnewListBuiltinCommand(),\n\t\tnewRemoveCommand(),\n\t\tnewSearchCommand(),\n\t\tnewShowCommand(loaderFn),\n\t)\n\n\treturn cmd\n}\n","sourceCodeStart":36,"sourceCodeEnd":71,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/cmd/picoclaw/internal/skills/command.go#L36-L71","documentation":"A skills subcommand asked for the workspace path but d.workspace is empty — either cfg.WorkspacePath() returned \"\" for the loaded config, or PersistentPreRunE never ran to populate it. It is a defensive guard used by workspaceFn(), which install-builtin and similar subcommands depend on.","triggerScenarios":"Invoking `picoclaw skills install-builtin` (the subcommand wired to workspaceFn at command.go:62) when the loaded config yields an empty WorkspacePath, or embedding the cobra command in a way that skips PersistentPreRunE (command.go:54).","commonSituations":"Fresh install where workspace initialization was never completed, a config.json copied without the workspace setting, or programmatic invocation (cmd.Execute on a subcommand directly) that bypasses the parent's PersistentPreRunE.","solutions":["Run picoclaw's workspace initialization (e.g. `picoclaw init`) so the config carries a workspace path.","Set the workspace explicitly in the config file picoclaw loads.","If invoking programmatically, execute via the parent `skills` command so PersistentPreRunE runs, or populate deps yourself.","Sanity-check with `picoclaw skills list`, which exercises the same loader path."],"exampleFix":"# before\npicoclaw skills install-builtin   # config has no workspace set\n# after\npicoclaw init                     # then retry\npicoclaw skills install-builtin","handlingStrategy":"validation","validationCode":"cfg, err := internal.LoadConfig()\nif err != nil {\n    return err\n}\nif cfg.WorkspacePath() == \"\" {\n    return fmt.Errorf(\"workspace is not configured — run `picoclaw init` first\")\n}","typeGuard":"func hasWorkspace(cfg *internal.Config) bool {\n    return cfg.WorkspacePath() != \"\"\n}","tryCatchPattern":null,"preventionTips":["Make workspace init a hard prerequisite in onboarding docs and scripts.","Assert a non-empty workspace in CI smoke tests of CLI flows.","Do not bypass PersistentPreRunE when embedding these cobra commands."],"tags":["config","workspace","cli","go"],"backgroundTag":null,"analyzedSha":"49183d7e8daed0dba89ddbb6fcb60089401d9680","analyzedAt":"2026-08-15T21:55:41.315Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}