siyuan-note/siyuan · error

--path must not be empty

Error message

--path must not be empty

What it means

The `siyuan asset clean` command accepts an optional --path flag to clean a single unused asset. If --path is explicitly provided but its value is an empty string, the command rejects it with this error rather than silently treating it as unset.

Solutions

  1. Either omit --path entirely (clean all unused assets) or supply a non-empty asset path.
  2. Fix the script variable that resolves to an empty string.
  3. Verify quoting so the shell passes the intended path as the flag value.

Example fix

// before
siyuan asset clean --path "$ASSET_PATH"   # ASSET_PATH empty
// after
siyuan asset clean   # or set ASSET_PATH to a real asset path
Defensive patterns

Strategy: validation

Validate before calling

if [ -n "${ASSET_PATH+x}" ] && [ -z "$ASSET_PATH" ]; then echo "--path given but empty"; exit 1; fi

Prevention

When it happens

Trigger: Running `asset clean --path ""` (flag marked as Changed but with empty value), optionally with --dry-run.

Common situations: Scripts interpolating an empty variable into --path; shell quoting dropping the intended value.

Understand the failure class

Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.

Related errors


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

Appendix: source

Thrown at kernel/cli/cmd/asset.go:144

			fmt.Fprintln(w, "PATH\tNAME")
			for _, item := range items {
				fmt.Fprintf(w, "%s\t%s\n", item.Item, item.Name)
			}
			w.Flush()
			fmt.Printf("\n%d unused asset(s)\n", len(items))
		}
		return nil
	},
}

var assetCleanCmd = &cobra.Command{
	Use:   "clean",
	Short: "Clean unused assets",
	RunE: func(cmd *cobra.Command, args []string) error {
		singlePath, _ := cmd.Flags().GetString("path")
		if cmd.Flags().Changed("path") {
			if singlePath == "" {
				return fmt.Errorf("--path must not be empty")
			}
			if dryRun {
				relativePath, _, err := model.ResolveUnusedDataAssetPath(singlePath)
				if err != nil {
					return err
				}
				fmt.Printf("[dry-run] Would remove unused asset: %s\n", relativePath)
				return nil
			}
			ret, err := model.RemoveUnusedAsset(singlePath)
			if err != nil {
				return err
			}
			fmt.Println(ret)
			return nil
		}

		if dryRun {

View on GitHub (pinned to 9f775e8a12)