siyuan-note/siyuan · error

notebook [ ] was created but could not be opened

Error message

notebook [%s] was created but could not be opened: %w

What it means

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.

Solutions

  1. Read the wrapped (%w) cause to identify why the mount failed and fix that root cause.
  2. Run `siyuan notebook open --id <printed-id>` to retry mounting the already-created notebook.
  3. Check workspace directory permissions and free disk space.
  4. Ensure no other kernel instance is running against the same workspace.

Example fix

// before: create failed midway, notebook left unmounted
siyuan notebook create --name "Notes"   // errors: created but could not be opened
// after: retry opening the existing ID
siyuan notebook open --id 20240101120000-abcd123
Defensive patterns

Strategy: try-catch

Validate before calling

# pre-check workspace writability and that no other kernel is running
test -w "$SIYUAN_WORKSPACE/data" || { echo "workspace not writable"; exit 1; }

Try / catch

out=$(siyuan notebook create --name "$NAME" 2>&1) || {
  id=$(echo "$out" | grep -oE '[0-9]{14}-[a-z0-9]+' | head -1)
  if [ -n "$id" ]; then siyuan notebook open --id "$id"; fi
}

Prevention

When it happens

Trigger: 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).

Common situations: Workspace directory permission problems; another SiYuan kernel instance holding locks on the same workspace; disk full or antivirus interference during index creation.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/b71cb3037ae02227. Report an issue: GitHub.

Appendix: source

Thrown at kernel/cli/cmd/notebook.go:82

	Use:   "create --name <name>",
	Short: "Create a notebook",
	RunE: func(cmd *cobra.Command, args []string) error {
		name, _ := cmd.Flags().GetString("name")
		if name == "" {
			return fmt.Errorf("--name is required")
		}

		if dryRun {
			fmt.Printf("[dry-run] Would create notebook \"%s\"\n", name)
			return nil
		}

		id, err := model.CreateBox(name)
		if err != nil {
			return err
		}
		if _, err = model.Mount(id); err != nil {
			return fmt.Errorf("notebook [%s] was created but could not be opened: %w", id, err)
		}
		model.AppendPushReloadFiletreeEntry()
		fmt.Println(id)
		return nil
	},
}

func formatNotebookWriteError(boxID string, err error) error {
	if errors.Is(err, model.ErrBoxClosed) {
		return fmt.Errorf("notebook [%s] is closed; run `notebook open --id %s` first", boxID, boxID)
	}
	if errors.Is(err, model.ErrBoxNotFound) {
		return fmt.Errorf("notebook [%s] not found", boxID)
	}
	return err
}

var notebookRemoveCmd = &cobra.Command{

View on GitHub (pinned to 9f775e8a12)