{"record":{"id":"9c86b2228c061c8d","repo":"midudev/autoskills","slug":"could-not-resolve-autoskills-package-version-for-registry","errorCode":null,"errorMessage":"could not resolve autoskills package version for registry download","messagePattern":"could not resolve autoskills package version for registry download","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/autoskills/installer.ts","lineNumber":192,"sourceCode":"  const rel = relative(from, to);\n  return rel.split(\"\\\\\").join(\"/\");\n}\n\nfunction normalizeRegistryRelPath(rel: string): string {\n  return rel.split(\"\\\\\").join(\"/\");\n}\n\nfunction sha256Buffer(buf: Buffer): string {\n  return createHash(\"sha256\").update(buf).digest(\"hex\");\n}\n\nfunction getRegistryRawBaseUrls(opts: InstallOptions): string[] {\n  const configured = opts.registryBaseUrl || process.env.AUTOSKILLS_REGISTRY_BASE_URL;\n  if (configured) return [configured.replace(/\\/+$/, \"\")];\n\n  const version = getPackageVersion();\n  if (!version) {\n    throw new Error(\"could not resolve autoskills package version for registry download\");\n  }\n\n  return [\n    `${DEFAULT_REGISTRY_RAW_BASE_URL_PREFIX}/v${version}/packages/autoskills/skills-registry`,\n    `${DEFAULT_REGISTRY_RAW_BASE_URL_PREFIX}/main/packages/autoskills/skills-registry`,\n  ];\n}\n\nfunction getInstallRegistryDir(opts: InstallOptions): string {\n  return opts.registryDir || getRegistryDir();\n}\n\nexport function getAutoskillsCacheDir(): string {\n  return (\n    process.env.AUTOSKILLS_CACHE_DIR || join(homedir(), \".cache\", \"autoskills\", \"skills-registry\")\n  );\n}\n","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/midudev/autoskills/blob/0ec725320d2137253ab2e68e7ba8a072148e741a/packages/autoskills/installer.ts#L174-L210","documentation":"getRegistryRawBaseUrls builds the GitHub raw-content base URLs used to download skill files from the skills-registry. When no explicit registryBaseUrl (option or AUTOSKILLS_REGISTRY_BASE_URL env var) is set, it derives the URL from the autoskills package's own version via getPackageVersion(). If that version cannot be resolved (e.g. package.json is unreadable or missing in the packaged/bundled install), it throws this error rather than guessing a version.","triggerScenarios":"Calling downloadRegistryFile (via downloadRegistryEntry -> install) with no opts.registryBaseUrl and no AUTOSKILLS_REGISTRY_BASE_URL set, while getPackageVersion() returns falsy — typically when the package was installed in a way that loses or renames package.json (bundlers, certain monorepo symlinks, trimmed publish artifacts).","commonSituations":"Running the CLI from a bundled/dist build that didn't ship package.json; running from a workspace where the package has no version field; exotic install layouts (pnpm hoisting oddities, copying source out of node_modules); CI sandboxes stripping files.","solutions":["Set the AUTOSKILLS_REGISTRY_BASE_URL environment variable to a registry raw base URL to bypass version resolution.","Pass registryBaseUrl in InstallOptions when calling the installer.","Ensure the autoskills package was installed normally (pnpm/npm install with lockfile) so its package.json with a version field is present.","Check that getPackageVersion()'s lookup path (package.json next to the module) was not stripped by your bundler/build config; include it as an asset if bundling."],"exampleFix":"// before\n$ autoskills install some-skill   // no env, broken package.json -> throws\n\n// after\n$ export AUTOSKILLS_REGISTRY_BASE_URL=https://raw.githubusercontent.com/org/repo/main/packages/autoskills/skills-registry\n$ autoskills install some-skill","handlingStrategy":"fallback","validationCode":"import { readFileSync, existsSync } from \"node:fs\";\nfunction canResolvePackageVersion(pkgDir) {\n  try {\n    const pkg = JSON.parse(readFileSync(join(pkgDir, \"package.json\"), \"utf-8\"));\n    return typeof pkg.version === \"string\" && pkg.version.length > 0;\n  } catch { return false; }\n}\nconst ready = canResolvePackageVersion(pkgDir) || !!process.env.AUTOSKILLS_REGISTRY_BASE_URL;","typeGuard":null,"tryCatchPattern":"try {\n  await install(opts);\n} catch (e) {\n  if (e.message.includes(\"could not resolve autoskills package version\")) {\n    await install({ ...opts, registryBaseUrl: process.env.AUTOSKILLS_REGISTRY_BASE_URL ?? FALLBACK_BASE_URL });\n  } else throw e;\n}","preventionTips":["Always install autoskills via a normal package manager install so package.json ships with a version.","Set AUTOSKILLS_REGISTRY_BASE_URL explicitly in CI and Docker images.","If bundling, configure the bundler to preserve package.json as an asset.","Smoke-test installs from the packaged artifact, not just from source."],"tags":["installation","version-resolution","missing-config","environment"],"backgroundTag":"missing-env-var","analyzedSha":"0ec725320d2137253ab2e68e7ba8a072148e741a","analyzedAt":"2026-09-15T14:12:31.090Z","contentChangedAt":"2026-09-15T14:12:31.090Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}