{"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/9f775e8a12daef8255556097396f9b2739078892/kernel/cli/cmd/notebook.go#L64-L100","documentation":"After `model.CreateBox` succeeds, the command immediately calls `model.Mount(id)` to open/index the new notebook. If mounting fails, the notebook has been created on disk but is unusable until mounted, so the error wraps the underlying mount failure together with the new notebook ID via %w.","triggerScenarios":"Calling `siyuan notebook create --name <name>` where CreateBox succeeds but model.Mount returns an error (e.g. filesystem issues in the workspace, index failure, lock conflicts with a running kernel).","commonSituations":"Workspace directory permission problems; another SiYuan kernel instance holding locks on the same workspace; disk full or antivirus interference during index creation.","solutions":["Read the wrapped (%w) cause to identify why the mount failed and fix that root cause.","Run `siyuan notebook open --id <printed-id>` to retry mounting the already-created notebook.","Check workspace directory permissions and free disk space.","Ensure no other kernel instance is running against the same workspace."],"exampleFix":"// before: create failed midway, notebook left unmounted\nsiyuan notebook create --name \"Notes\"   // errors: created but could not be opened\n// after: retry opening the existing ID\nsiyuan notebook open --id 20240101120000-abcd123","handlingStrategy":"try-catch","validationCode":"# pre-check workspace writability and that no other kernel is running\ntest -w \"$SIYUAN_WORKSPACE/data\" || { echo \"workspace not writable\"; exit 1; }","typeGuard":null,"tryCatchPattern":"out=$(siyuan notebook create --name \"$NAME\" 2>&1) || {\n  id=$(echo \"$out\" | grep -oE '[0-9]{14}-[a-z0-9]+' | head -1)\n  if [ -n \"$id\" ]; then siyuan notebook open --id \"$id\"; fi\n}","preventionTips":["Ensure the workspace directory is writable before creating notebooks","Avoid running two kernel instances on the same workspace","On failure, retry mounting with notebook open using the printed ID","Monitor disk space where the workspace lives"],"tags":["cli","mount","partial-failure"],"backgroundTag":"invalid-state-transition","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}