{"record":{"id":"b71cb3037ae02227","repo":"siyuan-note/siyuan","slug":"notebook-s-was-created-but-could-not-be-opened","errorCode":null,"errorMessage":"notebook [%s] was created but could not be opened: %w","messagePattern":"notebook \\[(.+?)\\] was created but could not be opened: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/cli/cmd/notebook.go","lineNumber":82,"sourceCode":"\tUse:   \"create --name <name>\",\n\tShort: \"Create a notebook\",\n\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\tname, _ := cmd.Flags().GetString(\"name\")\n\t\tif name == \"\" {\n\t\t\treturn fmt.Errorf(\"--name is required\")\n\t\t}\n\n\t\tif dryRun {\n\t\t\tfmt.Printf(\"[dry-run] Would create notebook \\\"%s\\\"\\n\", name)\n\t\t\treturn nil\n\t\t}\n\n\t\tid, err := model.CreateBox(name)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif _, err = model.Mount(id); err != nil {\n\t\t\treturn fmt.Errorf(\"notebook [%s] was created but could not be opened: %w\", id, err)\n\t\t}\n\t\tmodel.AppendPushReloadFiletreeEntry()\n\t\tfmt.Println(id)\n\t\treturn nil\n\t},\n}\n\nfunc formatNotebookWriteError(boxID string, err error) error {\n\tif errors.Is(err, model.ErrBoxClosed) {\n\t\treturn fmt.Errorf(\"notebook [%s] is closed; run `notebook open --id %s` first\", boxID, boxID)\n\t}\n\tif errors.Is(err, model.ErrBoxNotFound) {\n\t\treturn fmt.Errorf(\"notebook [%s] not found\", boxID)\n\t}\n\treturn err\n}\n\nvar notebookRemoveCmd = &cobra.Command{","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/cli/cmd/notebook.go#L64-L100","documentation":"Thrown by the `notebook create` subcommand when `model.CreateBox` succeeded (the notebook directory and metadata were written) but the subsequent `model.Mount` failed. This is a partial-state error: the notebook exists on disk but is not opened in the kernel, so it is not indexed or usable until manually opened. The underlying mount error is wrapped via `%w` so `errors.Is`/`errors.As` still see it.","triggerScenarios":"`CreateBox` returns a valid new box ID, then `Mount(id)` returns an error — e.g. the index queue fails, a file lock is contended, or the workspace is in a degraded state. The new ID is included in the message so the partial notebook is recoverable.","commonSituations":"Concurrent workspace access (another process holds a lock); low disk space or permissions issues during indexing; a corrupted workspace that mounts other notebooks but fails on the new one; kernel not fully initialized at create time.","solutions":["Open the partially-created notebook explicitly: `siyuan notebook open --id <id from message>`","If open still fails, inspect the wrapped error for the root cause (lock, permissions, disk)","Restart the kernel to release stale locks, then retry `notebook open`","As a last resort, remove the partial notebook (`notebook remove --id <id>`) and recreate it"],"exampleFix":"// before\nsiyuan notebook create --name Research\n# -> error: notebook [20240101-xyz] was created but could not be opened: <cause>\n// after\nsiyuan notebook open --id 20240101-xyz","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// After create, if Mount fails the notebook exists but is closed.\n// Capture the ID from the error and open it explicitly:\nid, createErr := model.CreateBox(name)\nif createErr != nil { return createErr }\nif _, err := model.Mount(id); err != nil {\n    // notebook id is now in a partial state; surface it for recovery\n    return fmt.Errorf(\"notebook [%s] created but not opened: %w; run `notebook open --id %s`\", id, err, id)\n}","preventionTips":["Parse the box ID out of the error and run `notebook open --id <id>` to recover","Ensure no other process holds the workspace lock before creating notebooks","Free disk space and fix permissions to avoid mount/index failures","On persistent mount failure, `notebook remove --id <id>` the partial box and recreate"],"tags":["cli","notebook","partial-state","mount","go","siyuan"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}