{"record":{"id":"eb327976bbc881c7","repo":"nikivdev/code","slug":"no-previous-task-found-for-this-project","errorCode":null,"errorMessage":"no previous task found for this project","messagePattern":"no previous task found for this project","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/main.rs","lineNumber":859,"sourceCode":"        | Some(Commands::Publish(_))\n        | Some(Commands::Clone(_))\n        | Some(Commands::TaskShortcut(_))\n        | Some(Commands::Agents(_))\n        | Some(Commands::Hive(_)) => StartupPolicy::SECRETS_ONLY,\n        Some(Commands::Undo(_)) => StartupPolicy::NONE,\n    }\n}\n\nfn rerun(opts: RerunOpts) -> Result<()> {\n    let project_root = if opts.config.is_absolute() {\n        opts.config.parent().unwrap_or(Path::new(\".\")).to_path_buf()\n    } else {\n        std::env::current_dir().unwrap_or_else(|_| Path::new(\".\").to_path_buf())\n    };\n\n    let record = history::load_last_record_for_project(&project_root)?;\n    let Some(rec) = record else {\n        bail!(\"no previous task found for this project\");\n    };\n\n    // Parse user_input to extract task name and args (respecting shell quoting)\n    let parts = shell_words::split(&rec.user_input).unwrap_or_else(|_| vec![rec.task_name.clone()]);\n    let task_name = parts.first().cloned().unwrap_or(rec.task_name.clone());\n    let args: Vec<String> = parts.into_iter().skip(1).collect();\n\n    println!(\"Re-running: {}\", rec.user_input);\n\n    tasks::run(TaskRunOpts {\n        config: opts.config,\n        delegate_to_hub: false,\n        hub_host: IpAddr::from([127, 0, 0, 1]),\n        hub_port: 9050,\n        name: task_name,\n        args,\n    })\n}","sourceCodeStart":841,"sourceCodeEnd":877,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/main.rs#L841-L877","documentation":"The rerun command re-executes the most recent task record saved for the current project directory; when history::load_last_record_for_project returns None there is nothing to replay, so rerun bails. It means the project simply has no recorded task history yet.","triggerScenarios":"Running `flow rerun` (without a project flag resolving to another directory) in a directory where no task was ever run, or after the history store was cleared/reset.","commonSituations":"Fresh clone of a repo without the local history file; running in a different subdirectory than where previous tasks ran (project root mismatch); deleting ~/.local/share-style history data.","solutions":["Run the desired task normally once — it will be recorded and rerun will then work.","Use the flag/argument to rerun against the correct project root where history exists.","Check where the history file is stored and confirm it was not deleted or moved."],"exampleFix":"# before\nflow rerun                 # in a fresh repo -> no previous task\n# after\nflow build && flow test    # run tasks first\nflow rerun                 # now replays the last one","handlingStrategy":"fallback","validationCode":"fn has_history(project_root: &Path) -> bool {\n    history::load_last_record_for_project(project_root)\n        .map(|r| r.is_some())\n        .unwrap_or(false)\n}\nif !has_history(&project_root) {\n    eprintln!(\"no previous task recorded; run a task first\");\n    return;\n}","typeGuard":"fn previous_task_known(rec: Option<history::Record>) -> bool {\n    rec.is_some()\n}","tryCatchPattern":"match rerun(opts) {\n    Err(e) if e.to_string() == \"no previous task found for this project\" => {\n        eprintln!(\"Nothing to rerun. Run a task first, e.g. `flow build`\");\n        std::process::exit(1);\n    }\n    other => other?,\n}","preventionTips":["Run the task normally at least once before relying on rerun.","Run rerun from the same project root where the original task executed.","Back up the history store if it matters to your workflow."],"tags":["task-runner","history","state"],"backgroundTag":"no-history-record-found","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}