{"record":{"id":"44810dd109223c6f","repo":"google-gemini/gemini-cli","slug":"tar-c-command-failed-to-create-tmparchivefile","errorCode":null,"errorMessage":"tar.c command failed to create ${tmpArchiveFile}","messagePattern":"tar\\.c command failed to create (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/a2a-server/src/persistence/gcs.ts","lineNumber":141,"sourceCode":"      );\n\n      if (await fse.pathExists(workDir)) {\n        const entries = await fsPromises.readdir(workDir);\n        if (entries.length > 0) {\n          const tmpArchiveFile = join(tmpdir(), getTmpArchiveFilename(taskId));\n          try {\n            await tar.c(\n              {\n                gzip: true,\n                file: tmpArchiveFile,\n                cwd: workDir,\n                portable: true,\n              },\n              entries,\n            );\n\n            if (!(await fse.pathExists(tmpArchiveFile))) {\n              throw new Error(\n                `tar.c command failed to create ${tmpArchiveFile}`,\n              );\n            }\n\n            const workspaceFile = this.storage\n              .bucket(this.bucketName)\n              .file(workspaceObjectPath);\n            const sourceStream = createReadStream(tmpArchiveFile);\n            const destStream = workspaceFile.createWriteStream({\n              contentType: 'application/gzip',\n              resumable: true,\n            });\n\n            await new Promise<void>((resolve, reject) => {\n              sourceStream.on('error', (err) => {\n                logger.error(\n                  `Error in source stream for ${tmpArchiveFile}:`,\n                  err,","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/google-gemini/gemini-cli/blob/5024443c7217464a66e98f80d73172a26440bd8f/packages/a2a-server/src/persistence/gcs.ts#L123-L159","documentation":"After tar.c() is invoked to create a gzipped archive of the workspace into a temp file, the code checks the output file exists. If tar.c() returned without throwing but the archive file is absent, this error fires — signaling a silent failure in the archiving step that the tar library did not surface as an exception.","triggerScenarios":"tar.c({ gzip: true, file: tmpArchiveFile, cwd: workDir, portable: true }, entries) completes without error, but fse.pathExists(tmpArchiveFile) returns false. This can happen with disk-full conditions in the OS temp directory, permission issues writing to tmpdir, or the tar library silently failing on unreadable entries.","commonSituations":"Temp directory (os.tmpdir()) is full or read-only; workDir entries are inaccessible due to permissions; tar npm package version incompatibility; the workspace directory was removed between the readdir and tar.c calls.","solutions":["Check available disk space in the OS temp directory (df /tmp).","Verify write permissions on os.tmpdir() for the running process.","Inspect whether workDir entries are readable by the process.","Update the 'tar' npm dependency to the latest compatible version."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"import { tmpdir } from 'node:os';\nimport fse from 'fs-extra';\n\nasync function canWriteToTmpdir(): Promise<boolean> {\n  const testFile = join(tmpdir(), `write-test-${Date.now()}`);\n  try {\n    await fse.writeFile(testFile, 'test');\n    await fse.remove(testFile);\n    return true;\n  } catch {\n    return false;\n  }\n}\n\n// Before save:\nif (!(await canWriteToTmpdir())) {\n  throw new Error('Temp directory is not writable');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await store.save(task);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('tar.c command failed')) {\n    // Check disk space, permissions, then retry or report\n    logger.error('Workspace archive creation failed. Check tmpdir disk space and permissions.');\n  }\n  throw e;\n}","preventionTips":["Monitor disk space in the OS temp directory.","Ensure the process has write permissions to os.tmpdir().","Keep the tar npm package updated to a compatible version.","Verify the workDir is readable before triggering a save."],"tags":["persistence","gcs","tar","filesystem","workspace"],"backgroundTag":null,"analyzedSha":"5024443c7217464a66e98f80d73172a26440bd8f","analyzedAt":"2026-08-12T06:01:53.711Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}