{"record":{"id":"0858a33331b6ca41","repo":"JuliusBrussee/caveman","slug":"no-provider-credential-detected-pass-provider","errorCode":null,"errorMessage":"no provider credential detected; pass --provider","messagePattern":"no provider credential detected; pass --provider","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/create-caveman-agent/src/index.ts","lineNumber":139,"sourceCode":"    \"TEMP\", \"TMP\", \"TMPDIR\", \"LANG\", \"LC_ALL\", \"LC_CTYPE\", \"TZ\", \"CI\", \"NO_COLOR\", \"FORCE_COLOR\",\n    \"HTTP_PROXY\", \"HTTPS_PROXY\", \"NO_PROXY\", \"http_proxy\", \"https_proxy\", \"no_proxy\",\n    \"NPM_CONFIG_CACHE\", \"NPM_CONFIG_REGISTRY\", \"NPM_CONFIG_USERCONFIG\",\n    \"npm_config_cache\", \"npm_config_registry\", \"npm_config_userconfig\",\n  ]) {\n    if (process.env[key] !== undefined) env[key] = process.env[key];\n  }\n  return env;\n}\n\nasync function chooseProvider(flag: string | undefined): Promise<Provider> {\n  if (flag !== undefined) return parseProvider(flag);\n  const detected: Provider[] = [];\n  if (process.env.ANTHROPIC_API_KEY) detected.push(\"anthropic\");\n  if (process.env.OPENAI_API_KEY) detected.push(\"openai\");\n  if (process.env.GEMINI_API_KEY || process.env.GOOGLE_API_KEY) detected.push(\"google\");\n  if (detected.length === 1) return detected[0]!;\n  if (!process.stdin.isTTY || !process.stdout.isTTY) {\n    throw new Error(\n      detected.length === 0\n        ? \"no provider credential detected; pass --provider\"\n        : \"multiple provider credentials detected; pass --provider\",\n    );\n  }\n  const rl = createInterface({ input: process.stdin, output: process.stdout });\n  try {\n    const answer = await rl.question(\"Provider (anthropic/openai/google): \");\n    return parseProvider(answer);\n  } finally {\n    rl.close();\n  }\n}\n\nfunction projectFiles(name: string, provider: Provider): Record<string, string> {\n  return {\n    \"package.json\": `${JSON.stringify({\n      name,","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/27d5a3981a347890211bb1bf2439e5c821a63bc9/packages/create-caveman-agent/src/index.ts#L121-L157","documentation":"With no --provider flag, the initializer infers the provider from credentials in the environment (ANTHROPIC_API_KEY, OPENAI_API_KEY, GEMINI_API_KEY/GOOGLE_API_KEY). Zero matches is only auto-resolvable in an interactive TTY (it would prompt); in non-interactive contexts — CI, piped stdin/stdout, scripts — there is nothing to prompt and no credential to infer, so it throws and tells you to pass --provider.","triggerScenarios":"Running the initializer in CI or with piped stdin/stdout where no ANTHROPIC_API_KEY, OPENAI_API_KEY, GEMINI_API_KEY, or GOOGLE_API_KEY is set in the environment.","commonSituations":"CI pipelines without provider secrets, local shells where the key lives in a different terminal session or direnv that was not loaded, or running the tool under another process (Docker, VS Code tasks) that strips the env.","solutions":["Pass the flag explicitly: `--provider anthropic` (or openai/google).","Or export the matching credential before running, e.g. `export ANTHROPIC_API_KEY=...`, so detection succeeds.","In CI, add the provider choice as a build parameter instead of relying on ambient credentials."],"exampleFix":"# before (CI, no env keys)\nnpm create @caveman-ai/agent@latest myapp\n# after\nnpm create @caveman-ai/agent@latest myapp --provider anthropic","handlingStrategy":"validation","validationCode":"const CREDS = [\"ANTHROPIC_API_KEY\", \"OPENAI_API_KEY\", \"GEMINI_API_KEY\", \"GOOGLE_API_KEY\"] as const;\nfunction providerUnambiguous(): boolean {\n  return CREDS.filter(k => Boolean(process.env[k])).length !== 0;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["In CI, always pass --provider explicitly rather than relying on ambient credentials.","Load the relevant .env before running non-interactively.","Remember the TTY prompt is the only fallback — pipes disable it."],"tags":["cli","environment","credentials","ci"],"backgroundTag":null,"analyzedSha":"27d5a3981a347890211bb1bf2439e5c821a63bc9","analyzedAt":"2026-08-15T09:26:11.751Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}