{"record":{"id":"7bd41f515d74d7fa","repo":"jdx/mise","slug":"could-not-reuse-the-fetched-setup-preview","errorCode":null,"errorMessage":"could not reuse the fetched setup preview","messagePattern":"could not reuse the fetched setup preview","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/history/sync/onboard.rs","lineNumber":472,"sourceCode":"/// discovers newer commits and recomputes against current local state.\nfn seed_confirmed_fetch(store: &Store, preview: &Store) -> Result<()> {\n    let _sync = run::lock(store)?;\n    seed_confirmed_fetch_locked(store, preview)\n}\n\nfn seed_confirmed_fetch_locked(store: &Store, preview: &Store) -> Result<()> {\n    let source = preview\n        .repo()\n        .ok_or_else(|| eyre::eyre!(\"preview requires git\"))?;\n    let destination = store\n        .repo()\n        .ok_or_else(|| eyre::eyre!(\"setup requires git\"))?;\n    let url = url::Url::from_file_path(source.dir())\n        .map_err(|_| eyre::eyre!(\"cannot address the preview repository\"))?;\n    let refspec = format!(\"+{UPSTREAM_REF}:{UPSTREAM_REF}\");\n    let copied = destination.network([\"fetch\", \"--no-tags\", \"--\", url.as_str(), &refspec])?;\n    if !copied.status.success() {\n        bail!(\"could not reuse the fetched setup preview\");\n    }\n    Ok(())\n}\n\nfn detach_local_history(store: &Store) -> Result<Option<HistoryReplacement>> {\n    use crate::system::history::shadow::HistoryRepo;\n\n    let repo = store\n        .repo()\n        .ok_or_else(|| eyre::eyre!(\"setup requires git\"))?;\n    let Some(local) = repo.ref_oid(HistoryRepo::HISTORY_REF)? else {\n        return Ok(None);\n    };\n    let remote = repo\n        .ref_oid(UPSTREAM_REF)?\n        .ok_or_else(|| eyre::eyre!(\"setup repository has no fetched branch\"))?;\n    repo.delete_history_head(&local)?;\n    Ok(Some(HistoryReplacement { local, remote }))","sourceCodeStart":454,"sourceCodeEnd":490,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/history/sync/onboard.rs#L454-L490","documentation":"Onboarding reuses an already-fetched setup preview by copying its ref from the source repository into the destination via `git fetch`. If the fetch command exits nonzero — corrupt preview repo, missing ref, network/permission problem — mise reports it cannot reuse the fetched preview and the caller must re-fetch.","triggerScenarios":"seed_confirmed_fetch_locked builds a fetch of `+{UPSTREAM_REF}:{UPSTREAM_REF}` from the preview source path into the destination, and `copied.status.success()` is false.","commonSituations":"The preview repository was garbage-collected or re-cloned so UPSTREAM_REF is missing; filesystem permission issues in the destination repo; a partially deleted state dir after an interrupted run.","solutions":["Re-run the onboarding/setup command so the preview is fetched fresh","Delete the stale state dir / destination preview repo and retry","Verify the source preview repo still exists and contains the upstream ref"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// verify the preview ref exists before reusing\nlet has_ref = destination.network([\"rev-parse\", \"--verify\", UPSTREAM_REF]).map(|o| o.status.success()).unwrap_or(false);\nif !has_ref { eprintln!(\"preview missing; re-fetching\"); }","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"could not reuse the fetched setup preview\") => {\n        // drop the stale preview and re-run the fetch from scratch\n    }\n    _ => {}\n}","preventionTips":["Re-run setup after any interrupted sync instead of reusing state","Avoid deleting or re-cloning the preview repository mid-onboarding","Check disk/permissions on the state dir before starting onboarding"],"tags":["git","sync","fetch","stale-state"],"backgroundTag":"git-command-failed","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}