{"record":{"id":"196cf9bd3b95d654","repo":"sinelaw/fresh","slug":"pkg-failed-to-clone-registry-source-result-stderr","errorCode":null,"errorMessage":"[pkg] Failed to clone registry ${source}: ${result.stderr}","messagePattern":"\\[pkg\\] Failed to clone registry (.+?): (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/fresh-editor/plugins/pkg.ts","lineNumber":523,"sourceCode":"        errors.push(`${source}: ${errorMsg}`);\n        editor.warn(`[pkg] Failed to update registry ${source}: ${result.stderr}`);\n      }\n    } else {\n      // Clone new\n      editor.setStatus(`Cloning registry: ${source}...`);\n      const result = await gitCommand([\"clone\", \"--depth\", \"1\", `${source}`, `${indexPath}`]);\n      if (result.exit_code === 0) {\n        synced++;\n      } else {\n        const errorMsg = result.stderr.includes(\"Could not resolve host\")\n          ? \"Network error\"\n          : result.stderr.includes(\"not found\") || result.stderr.includes(\"404\")\n          ? \"Repository not found\"\n          : result.stderr.includes(\"Authentication\") || result.stderr.includes(\"403\")\n          ? \"Authentication failed (check if repo is public)\"\n          : result.stderr.split(\"\\n\")[0] || \"Unknown error\";\n        errors.push(`${source}: ${errorMsg}`);\n        editor.warn(`[pkg] Failed to clone registry ${source}: ${result.stderr}`);\n      }\n    }\n  }\n\n  // Cache registry data locally for faster startup next time\n  if (synced > 0) {\n    await cacheRegistry();\n  }\n\n  if (errors.length > 0) {\n    editor.setStatus(`Registry: ${synced}/${sources.length} synced. Errors: ${errors.join(\"; \")}`);\n  } else {\n    editor.setStatus(`Registry synced (${synced}/${sources.length} sources)`);\n  }\n}\n\n/**\n * Load merged registry data from git index or cache","sourceCodeStart":505,"sourceCodeEnd":541,"githubUrl":"https://github.com/sinelaw/fresh/blob/67894ca5463dbd7a89bb31add4627c27d6b79d83/crates/fresh-editor/plugins/pkg.ts#L505-L541","documentation":"`editor.warn` from `syncRegistry` in pkg.ts:523, emitted when cloning a new registry fails: `[pkg] Failed to clone registry ${source}: ${result.stderr}`. The plugin surfaces raw git clone stderr; packages from that registry are unavailable until the clone succeeds.","triggerScenarios":"First-time `git clone --depth 1 <source> <indexPath>` exits non-zero: host not resolvable, 404 / repo not found, auth required (private repo, 403), or local clone path issues.","commonSituations":"Typo'd or removed registry URL; private registry without credentials; offline/blocked network; index directory not writable or pre-existing partial clone blocking the clone.","solutions":["Correct the registry source URL in the pkg configuration","Ensure credentials are available (HTTPS token or SSH key) for private registries","Remove any partial/existing directory at `indexPath` and re-run sync","Check network connectivity / proxy; the warn text maps 'Could not resolve host' to Network error"],"exampleFix":"// before\neditor.warn(`[pkg] Failed to clone registry ${source}: ${result.stderr}`);\n// after\nif (result.stderr.includes(\"not found\") || result.exit_code === 128) {\n  editor.warn(`[pkg] Registry not found, check URL: ${source}`);\n}","handlingStrategy":"retry","validationCode":"// validate before cloning\nif (!/^([\\w.-]+@)?[\\w.-]+[:/][\\w./-]+$/.test(source)) { editor.warn(`[pkg] Bad registry URL: ${source}`); return; }\n// ensure target path is clean\nif (fsLocal.exists(indexPath)) fsLocal.removePath(indexPath);","typeGuard":"function isCloneableUrl(source) { return /^https:\\/\\/.+/.test(source) || /^git@.+/.test(source); }","tryCatchPattern":"const result = await gitCommand(['clone','--depth','1',source,indexPath]);\nif (result.exit_code !== 0) {\n  if (result.stderr.includes('not found') || result.stderr.includes('404')) { editor.warn(`[pkg] Registry not found: ${source}`); return; }\n  if (attempt < 2) return cloneWithRetry(source, attempt + 1);\n  editor.warn(`[pkg] Failed to clone registry ${source}: ${result.stderr}`);\n}","preventionTips":["Verify registry URLs with git ls-remote before first clone","Set up credentials (SSH keys or HTTPS tokens) for private registries","Clear partial clones at indexPath before retrying","Provide default public registry fallbacks in plugin config"],"tags":["git","clone","network","plugin"],"backgroundTag":"git-command-failed","analyzedSha":"67894ca5463dbd7a89bb31add4627c27d6b79d83","analyzedAt":"2026-09-13T15:04:03.701Z","contentChangedAt":"2026-09-13T15:04:03.701Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}