{"record":{"id":"c8dfb7730065778b","repo":"paperclipai/paperclip","slug":"choose-either-canary-or-version-not-both","errorCode":null,"errorMessage":"Choose either --canary or --version, not both.","messagePattern":"Choose either --canary or --version, not both\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/src/commands/install.ts","lineNumber":97,"sourceCode":"    ordered.push(entry);\n  };\n\n  visit(\"@paperclipai/server\");\n  return ordered;\n}\n\nfunction assertSupportedNodeVersion(): void {\n  const major = Number(process.versions.node.split(\".\")[0]);\n  if (!Number.isFinite(major) || major < 20) {\n    throw new Error(`Managed installs require Node.js 20 or newer (found ${process.version}).`);\n  }\n}\n\nexport function resolveNpmInstallRequest(options: InstallOptions): {\n  spec: string;\n  channel: InstallChannel;\n} {\n  if (options.canary && options.version) throw new Error(\"Choose either --canary or --version, not both.\");\n  if (options.version) {\n    const version = options.version.trim();\n    if (!EXACT_VERSION_PATTERN.test(version)) {\n      throw new Error(`--version requires an exact published version, received '${options.version}'.`);\n    }\n    return { spec: version, channel: \"pinned\" };\n  }\n  return options.canary ? { spec: \"canary\", channel: \"canary\" } : { spec: \"latest\", channel: \"latest\" };\n}\n\nfunction parseResolvedVersion(stdout: string): string {\n  const trimmed = stdout.trim();\n  if (!trimmed) throw new Error(\"npm returned an empty version response.\");\n  try {\n    const parsed = JSON.parse(trimmed) as unknown;\n    if (typeof parsed === \"string\") return parsed;\n  } catch {\n    if (EXACT_VERSION_PATTERN.test(trimmed)) return trimmed;","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/cli/src/commands/install.ts#L79-L115","documentation":"Thrown by resolveNpmInstallRequest (install.ts:97) when both --canary and --version are set. The two flags select mutually exclusive install channels (canary tag vs a pinned exact version), so specifying both is ambiguous and rejected up front.","triggerScenarios":"Running `paperclipai install --canary --version 1.2.3`. The guard fires immediately, before any version normalization or network call.","commonSituations":"Copy-pasting a command that accumulated both flags, or a wrapper script that always sets --canary and forwards a user-provided --version.","solutions":["Pick one channel: either --canary OR --version <exact>.","In scripts, set only one of the two based on intent.","For reproducible installs, prefer --version with a pinned semver."],"exampleFix":"// before\npaperclipai install --canary --version 1.2.3\n// after\npaperclipai install --version 1.2.3","handlingStrategy":"validation","validationCode":"function resolveChannel(opts: InstallOptions): 'canary' | 'pinned' | 'latest' {\n  if (opts.canary && opts.version) {\n    throw new Error('Pass either --canary or --version, not both.');\n  }\n  if (opts.version) return 'pinned';\n  return opts.canary ? 'canary' : 'latest';\n}","typeGuard":"function isMutuallyExclusiveFlags(opts: InstallOptions): boolean {\n  return !(opts.canary && opts.version);\n}","tryCatchPattern":null,"preventionTips":["Set exactly one of --canary or --version.","In wrapper scripts, clear the other flag when one is provided.","Prefer --version for reproducible installs."],"tags":["cli","install","argument-validation","conflicting-flags"],"backgroundTag":null,"analyzedSha":"67001ec6eb96ae601aa27bc91d9b2415d665334a","analyzedAt":"2026-08-12T12:05:45.408Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}