siyuan-note/siyuan · error
--label is required
Error message
--label is required
What it means
The `bookmark remove` CLI command requires the --label flag identifying which bookmark to delete. When the flag is missing or empty, RunE returns this error (kernel/cli/cmd/bookmark.go:78) before calling model.RemoveBookmark.
Solutions
- Pass the exact bookmark label: --label "MyBookmark"
- List existing bookmarks first (bookmark list) to get the exact label, including case and whitespace
- Check flag spelling (--label, not --name or --bookmark)
Example fix
// before siyuan bookmark remove // after siyuan bookmark remove --label "TODO"
Defensive patterns
Strategy: validation
Validate before calling
if [ -z "$LABEL" ]; then echo "--label is required" >&2; exit 1; fi siyuan bookmark remove --label "$LABEL"
Prevention
- Pass --label explicitly with the exact bookmark text
- Look up exact labels via bookmark list before removing
- Use --dry-run first to confirm the target bookmark
When it happens
Trigger: Running `siyuan bookmark remove` without --label, with `--label ""`, or with a misspelled flag so GetString returns the empty default.
Common situations: Interactive shell line-editing dropping the flag; scripts where the bookmark label variable is empty; assuming the label is a positional argument.
Understand the failure class
Background: "--flag is required" and "must specify" CLI errors: how missing-required-flag validation works and how to fix it — this error's family across 20 libraries.
Related errors
- --new is required
- --old is required
- --av and --ids are required
- --av, --key, --item and --value are required
- --block is required for non-detached rows
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/89a6d4680c6de3b5.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/cli/cmd/bookmark.go:78
default:
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
fmt.Fprintln(w, "LABEL")
for _, l := range labels {
fmt.Fprintln(w, l)
}
w.Flush()
}
return nil
},
}
var bookmarkRemoveCmd = &cobra.Command{
Use: "remove --label <label>",
Short: "Remove a bookmark",
RunE: func(cmd *cobra.Command, args []string) error {
label, _ := cmd.Flags().GetString("label")
if label == "" {
return fmt.Errorf("--label is required")
}
if dryRun {
fmt.Printf("[dry-run] Would remove bookmark \"%s\"\n", label)
return nil
}
if err := model.RemoveBookmark(label); err != nil {
return err
}
model.AppendPushReloadFiletreeEntry()
return nil
},
}
var bookmarkRenameCmd = &cobra.Command{
Use: "rename --old <old> --new <new>",
Short: "Rename a bookmark",View on GitHub (pinned to 9f775e8a12)