google-gemini/gemini-cli · error · Error

tar.c command failed to create ${tmpArchiveFile}

Error message

tar.c command failed to create ${tmpArchiveFile}

What it means

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.

Source

Thrown at packages/a2a-server/src/persistence/gcs.ts:141

      );

      if (await fse.pathExists(workDir)) {
        const entries = await fsPromises.readdir(workDir);
        if (entries.length > 0) {
          const tmpArchiveFile = join(tmpdir(), getTmpArchiveFilename(taskId));
          try {
            await tar.c(
              {
                gzip: true,
                file: tmpArchiveFile,
                cwd: workDir,
                portable: true,
              },
              entries,
            );

            if (!(await fse.pathExists(tmpArchiveFile))) {
              throw new Error(
                `tar.c command failed to create ${tmpArchiveFile}`,
              );
            }

            const workspaceFile = this.storage
              .bucket(this.bucketName)
              .file(workspaceObjectPath);
            const sourceStream = createReadStream(tmpArchiveFile);
            const destStream = workspaceFile.createWriteStream({
              contentType: 'application/gzip',
              resumable: true,
            });

            await new Promise<void>((resolve, reject) => {
              sourceStream.on('error', (err) => {
                logger.error(
                  `Error in source stream for ${tmpArchiveFile}:`,
                  err,

View on GitHub (pinned to 5024443c72)

Solutions

  1. Check available disk space in the OS temp directory (df /tmp).
  2. Verify write permissions on os.tmpdir() for the running process.
  3. Inspect whether workDir entries are readable by the process.
  4. Update the 'tar' npm dependency to the latest compatible version.
Defensive patterns

Strategy: try-catch

Validate before calling

import { tmpdir } from 'node:os';
import fse from 'fs-extra';

async function canWriteToTmpdir(): Promise<boolean> {
  const testFile = join(tmpdir(), `write-test-${Date.now()}`);
  try {
    await fse.writeFile(testFile, 'test');
    await fse.remove(testFile);
    return true;
  } catch {
    return false;
  }
}

// Before save:
if (!(await canWriteToTmpdir())) {
  throw new Error('Temp directory is not writable');
}

Try / catch

try {
  await store.save(task);
} catch (e) {
  if (e instanceof Error && e.message.includes('tar.c command failed')) {
    // Check disk space, permissions, then retry or report
    logger.error('Workspace archive creation failed. Check tmpdir disk space and permissions.');
  }
  throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of google-gemini/gemini-cli@5024443c72 (2026-08-12). Data as JSON: /api/errors/44810dd109223c6f. Report an issue: GitHub.