sipeed/picoclaw · error

error loading config: %w

Error message

error loading config: %w

What it means

Every `picoclaw cron <subcommand>` first runs the command's PersistentPreRunE, which loads the config (internal.LoadConfig) to compute storePath = <workspace>/cron/jobs.json shared by list/add/remove/enable/disable. This error means that config load failed before any subcommand logic ran.

Source

Thrown at cmd/picoclaw/internal/cron/command.go:28

)

func NewCronCommand() *cobra.Command {
	var storePath string

	cmd := &cobra.Command{
		Use:     "cron",
		Aliases: []string{"c"},
		Short:   "Manage scheduled tasks",
		Args:    cobra.NoArgs,
		RunE: func(cmd *cobra.Command, _ []string) error {
			return cmd.Help()
		},
		// Resolve storePath at execution time so it reflects the current config
		// and is shared across all subcommands.
		PersistentPreRunE: func(_ *cobra.Command, _ []string) error {
			cfg, err := internal.LoadConfig()
			if err != nil {
				return fmt.Errorf("error loading config: %w", err)
			}
			storePath = filepath.Join(cfg.WorkspacePath(), "cron", "jobs.json")
			return nil
		},
	}

	cmd.AddCommand(
		newListCommand(func() string { return storePath }),
		newAddCommand(func() string { return storePath }),
		newRemoveCommand(func() string { return storePath }),
		newEnableCommand(func() string { return storePath }),
		newDisableCommand(func() string { return storePath }),
	)

	return cmd
}

View on GitHub (pinned to 49183d7e8d)

Solutions

  1. Repair the config first: run `picoclaw config path`, fix syntax/permissions, or re-run onboarding
  2. Unset or correct PICOCLOW_HOME if it was overridden
  3. Retry the cron subcommand once other picoclaw commands load config without error
Defensive patterns

Strategy: validation

Validate before calling

picoclaw config validate && picoclaw cron list  # run the cheap config check first; fix any error before other cron subcommands

Prevention

When it happens

Trigger: Any `picoclaw cron list|add|remove|enable|disable` when the config file is missing, unreadable, or fails parsing/validation, or the workspace path cannot be derived from it.

Common situations: First run before onboarding/init completed; hand-edited config with syntax errors; PICOCLOW_HOME pointing somewhere wrong; running as a user without read access to the config.

Related errors


AI-assisted analysis of sipeed/picoclaw@49183d7e8d (2026-08-15). Data as JSON: /api/errors/a05545c967c6ee77. Report an issue: GitHub.