{"record":{"id":"2b487725e92d6d01","repo":"windmill-labs/windmill","slug":"no-instance-found-please-add-one-first","errorCode":null,"errorMessage":"No instance found, please add one first","messagePattern":"No instance found, please add one first","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/src/commands/instance/instance.ts","lineNumber":240,"sourceCode":"  }\n  // Try to use the active workspace profile's remote as a fallback\n  if (instances.length < 1) {\n    try {\n      const ws = await getActiveWorkspace({});\n      if (ws?.remote && ws?.token) {\n        const remote = ws.remote.endsWith(\"/\") ? ws.remote.slice(0, -1) : ws.remote;\n        setClient(ws.token, remote);\n        return {\n          name: ws.name,\n          remote: ws.remote,\n          token: ws.token,\n          prefix: ws.name,\n        };\n      }\n    } catch { /* ignore */ }\n  }\n  if (!allowNew && instances.length < 1) {\n    throw new Error(\"No instance found, please add one first\");\n  }\n  const instanceName = await getActiveInstance(opts);\n  let instance: Instance | undefined = instances.find(\n    (i) => i.name === instanceName,\n  );\n  if (!instance) {\n    if (instances.length < 1) {\n      instance = await addInstance({}, undefined, undefined, undefined);\n    } else {\n      const choice = (await Select.prompt({\n        message: \"Select an instance\",\n        options: [\n          ...instances.map((i) => ({\n            name: `${i.name} (${i.remote})`,\n            value: i.name,\n          })),\n          { name: \"Add new instance\", value: \"new\" },\n        ],","sourceCodeStart":222,"sourceCodeEnd":258,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/cli/src/commands/instance/instance.ts#L222-L258","documentation":"pickInstance resolves which Windmill instance profile the CLI should operate on from locally saved instances. When no instance name can be interactively chosen (allowNew is false) and there are zero saved profiles, it throws this error telling you to add one first.","triggerScenarios":"Calling any command that needs an instance config (wmill instance, whoami, getConfig, worker-group pull/push, etc.) on a machine where 'wmill instance add' has never been run, in non-interactive mode where creating a new instance is not allowed.","commonSituations":"Fresh CI runner or container with no ~/.wmill config; running the CLI under a different user/home than where the instance was added; deleted or missing global settings file.","solutions":["Run 'wmill instance add' and provide the instance URL and token","In CI, set the required env config or pre-seed the CLI config file before running commands","Verify you run as the same user/HOME that holds the existing wmill config","List what the CLI sees with 'wmill instance list' (or equivalent) to confirm the config path"],"exampleFix":"// before: command fails because no profile exists\nwmill whoami\n// after: register the instance first\nwmill instance add https://app.windmill.dev <token> --name prod\nwmill whoami","handlingStrategy":"validation","validationCode":"import { allInstances } from \"...\"; // or check config file\nconst hasInstance = (await allInstances()).length > 0;\nif (!hasInstance) {\n  throw new Error(\"Run 'wmill instance add' before this command\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  await wmillInstanceCommand();\n} catch (e) {\n  if (String(e).includes(\"No instance found\")) {\n    console.error(\"Register an instance first: wmill instance add <url> <token>\");\n  }\n}","preventionTips":["Run 'wmill instance add' as a first step in new environments/CI images","Pin the same HOME/user between setup and usage so the config is found","Seed the CLI config file in container images","Verify with 'wmill instance list' before scripted runs"],"tags":["cli","configuration","setup"],"backgroundTag":"missing-config-profile","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}