{"record":{"id":"b5c79f0b8494c621","repo":"google-gemini/gemini-cli","slug":"lxc-container-containername-not-found-create","errorCode":null,"errorMessage":"LXC container '${containerName}' not found. Create one with: lxc launch ubuntu:24.04 ${containerName}","messagePattern":"LXC container '(.+?)' not found\\. Create one with: lxc launch ubuntu:24\\.04 (.+?)","errorType":"exception","errorClass":"FatalSandboxError","httpStatus":null,"severity":"error","filePath":"packages/cli/src/utils/sandbox.ts","lineNumber":955,"sourceCode":"        .filter(\n          (item): item is Record<string, unknown> =>\n            item !== null &&\n            typeof item === 'object' &&\n            'name' in item &&\n            'status' in item,\n        )\n        .map((item) => ({\n          name: String(item['name']),\n          status: String(item['status']),\n        }));\n    }\n  } catch {\n    containers = [];\n  }\n\n  const container = containers.find((c) => c.name === containerName);\n  if (!container) {\n    throw new FatalSandboxError(\n      `LXC container '${containerName}' not found. ` +\n        `Create one with: lxc launch ubuntu:24.04 ${containerName}`,\n    );\n  }\n  if (container.status.toLowerCase() !== 'running') {\n    throw new FatalSandboxError(\n      `LXC container '${containerName}' is not running (current status: ${container.status}). ` +\n        `Start it with: lxc start ${containerName}`,\n    );\n  }\n\n  const devicesToRemove: string[] = [];\n  const removeDevices = () => {\n    for (const deviceName of devicesToRemove) {\n      try {\n        spawnSync(\n          'lxc',\n          ['config', 'device', 'remove', containerName, deviceName],","sourceCodeStart":937,"sourceCodeEnd":973,"githubUrl":"https://github.com/google-gemini/gemini-cli/blob/5024443c7217464a66e98f80d73172a26440bd8f/packages/cli/src/utils/sandbox.ts#L937-L973","documentation":"Thrown when `lxc list` succeeded and returned JSON, but no container with the expected name was found in the parsed list. The container must exist before it can be used as a sandbox. The message gives the exact creation command.","triggerScenarios":"containers.find((c) => c.name === containerName) returns undefined after a successful lxc list query. Container was never created, was deleted, or containerName in config differs from what exists.","commonSituations":"First use of the LXC sandbox without provisioning the container. containerName changed in config. Container was removed by a cleanup script or another user. Typo in the configured container name.","solutions":["Create the container with the exact name: `lxc launch ubuntu:24.04 <containerName>`.","List existing containers (`lxc list`) and either match the config name to one of them or rename the container.","Set config.containerName (or the equivalent setting) to the name of an existing container."],"exampleFix":"// before: container 'gemini-sandbox' does not exist\n// config.containerName = 'gemini-sandbox'\n\n// after\n// lxc launch ubuntu:24.04 gemini-sandbox","handlingStrategy":"validation","validationCode":"const { execSync } = require('child_process');\nfunction ensureContainerExists(name) {\n  const out = execSync(`lxc list ${name} --format=json`, {encoding:'utf8'});\n  const list = JSON.parse(out);\n  if (!list.some(c => c.name === name)) {\n    execSync(`lxc launch ubuntu:24.04 ${name}`, {stdio:'inherit'});\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Provision the named container in your setup script.","Keep the configured containerName consistent across environments."],"tags":["sandbox","lxc","lxd","container","provisioning"],"backgroundTag":null,"analyzedSha":"5024443c7217464a66e98f80d73172a26440bd8f","analyzedAt":"2026-08-12T06:01:53.711Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}