{"record":{"id":"f2ea401997e93ebf","repo":"jdx/mise","slug":"could-not-snapshot-the-local-history-repository-fo","errorCode":null,"errorMessage":"could not snapshot the local history repository for preview","messagePattern":"could not snapshot the local history repository for preview","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/history/sync/onboard.rs","lineNumber":68,"sourceCode":"/// All fetches, reconciliation, and preview status writes then target this\n/// private store, so cancellation never needs to roll back live bookkeeping.\nfn preview_store(store: &Store) -> Result<(tempfile::TempDir, Store)> {\n    let _sync = run::lock(store)?;\n    let _capture = store.lock()?;\n    let temp = tempfile::tempdir()?;\n    hstore::ensure_store_dir_in(temp.path())?;\n    let preview = Store::open_in(temp.path())?;\n    let source = store\n        .repo()\n        .ok_or_else(|| eyre::eyre!(\"preview requires git\"))?;\n    let destination = preview\n        .repo()\n        .ok_or_else(|| eyre::eyre!(\"preview requires git\"))?;\n    let url = url::Url::from_file_path(source.dir())\n        .map_err(|_| eyre::eyre!(\"cannot address the local history repository\"))?;\n    let copied = destination.network([\"fetch\", \"--no-tags\", url.as_str(), \"+refs/*:refs/*\"])?;\n    if !copied.status.success() {\n        bail!(\"could not snapshot the local history repository for preview\");\n    }\n    run::write_status(temp.path(), &run::read_status(store.state_dir())?)?;\n    // Reopen to rebuild the derived history index from the copied commits.\n    let preview = Store::open_in(temp.path())?;\n    Ok((temp, preview))\n}\n\nfn preview_configuration(store: &Store) -> Result<tempfile::TempDir> {\n    let temp = tempfile::tempdir()?;\n    let repo = store\n        .repo()\n        .ok_or_else(|| eyre::eyre!(\"preview requires git\"))?;\n    let head = repo\n        .ref_oid(UPSTREAM_REF)?\n        .ok_or_else(|| eyre::eyre!(\"setup preview has no fetched branch\"))?;\n    let encrypted = super::files::encrypted_paths(repo, Some(&head))?;\n    let tracked = crate::system::history::manifest::Manifest::read(repo, &head)?\n        .ok_or_else(|| eyre::eyre!(\"setup repository has no enrollment metadata\"))?","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/system/history/sync/onboard.rs#L50-L86","documentation":"preview_store creates a temporary store and fetches all refs from the local history repository to snapshot it. If the underlying git fetch command exits non-zero, the snapshot cannot be produced, so the library bails with this error rather than previewing incomplete history.","triggerScenarios":"The `git fetch --no-tags <file-url> +refs/*:refs/*` spawned in preview_store fails (non-zero status) — e.g. the source repo has no refs, the file-path URL is wrong, or git itself is broken/absent in the temp store.","commonSituations":"Running onboarding preview against an empty or freshly initialized history repository with no refs to copy; filesystem permission problems on the temp dir; a corrupted or partially initialized source repository.","solutions":["Ensure the source history repository has refs (git for-each-ref) — an empty repo cannot be snapshotted.","Re-run git fetch with the same file URL manually to see the underlying git error and fix it.","Check permissions on the temp directory and the source repository path.","Confirm git is installed and functional (git --version) since preview requires git."],"exampleFix":"// ensure source has refs before preview\nif repo.for_each_ref()?.is_empty() {\n    eyre::bail!(\"source history repository has no refs to preview\");\n}\nlet copied = destination.network([\"fetch\", \"--no-tags\", url.as_str(), \"+refs/*:refs/*\"])?;","handlingStrategy":"try-catch","validationCode":"// check source repo has refs and git works before preview\nassert!(Path::new(&source.dir()).join(\".git\").exists() || source.dir().join(\"HEAD\").exists());\nlet has_refs = !repo.for_each_ref()?.is_empty();","typeGuard":null,"tryCatchPattern":"match preview_store(&source) {\n    Err(e) if e.to_string().contains(\"could not snapshot\") => {\n        eprintln!(\"snapshot fetch failed; run the fetch manually to see git's error\");\n    }\n    other => other?,\n}","preventionTips":["Ensure the history repository has at least one ref before previewing.","Keep git installed and healthy where the preview runs.","Check temp-dir permissions and disk space.","Run the equivalent fetch by hand to diagnose the underlying git failure."],"tags":["git","fetch","preview","snapshot"],"backgroundTag":"git-command-failed","analyzedSha":"afd2eddd3a50c16190efc1c7e94404b48f72af57","analyzedAt":"2026-09-09T01:38:25.179Z","contentChangedAt":"2026-09-09T01:38:25.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}