firecrawl/open-lovable · error · Error
Failed to create zip: ${error}
Error message
Failed to create zip: ${error} What it means
Thrown when a `zip -r /tmp/project.zip` command executed inside the sandbox exits with a non-zero status. The command's stderr is captured and embedded in the message, so the actual zip failure reason (missing files, no write permission, zip binary missing) is in the error text.
Source
Thrown at app/api/create-zip/route.ts:26
try {
if (!global.activeSandbox) {
return NextResponse.json({
success: false,
error: 'No active sandbox'
}, { status: 400 });
}
console.log('[create-zip] Creating project zip...');
// Create zip file in sandbox using standard commands
const zipResult = await global.activeSandbox.runCommand({
cmd: 'bash',
args: ['-c', `zip -r /tmp/project.zip . -x "node_modules/*" ".git/*" ".next/*" "dist/*" "build/*" "*.log"`]
});
if (zipResult.exitCode !== 0) {
const error = await zipResult.stderr();
throw new Error(`Failed to create zip: ${error}`);
}
const sizeResult = await global.activeSandbox.runCommand({
cmd: 'bash',
args: ['-c', `ls -la /tmp/project.zip | awk '{print $5}'`]
});
const fileSize = await sizeResult.stdout();
console.log(`[create-zip] Created project.zip (${fileSize.trim()} bytes)`);
// Read the zip file and convert to base64
const readResult = await global.activeSandbox.runCommand({
cmd: 'base64',
args: ['/tmp/project.zip']
});
if (readResult.exitCode !== 0) {
const error = await readResult.stderr();View on GitHub (pinned to 69bd93bae7)
Solutions
- Read the `error` field of the thrown message — it contains the zip stderr (e.g. 'zip: command not found')
- Install zip in the sandbox image or fall back to a different compressor (`tar czf` is usually available)
- Verify the project directory exists and is non-empty before zipping
- Retry by re-creating the sandbox if the filesystem was reset
Example fix
// before
if (zipResult.exitCode !== 0) {
const error = await zipResult.stderr();
throw new Error(`Failed to create zip: ${error}`);
}
// after
if (zipResult.exitCode !== 0) {
let error = await zipResult.stderr();
if (/command not found/.test(error)) {
await global.activeSandbox.runCommand({ cmd: 'bash', args: ['-c', 'apt-get install -y zip'] });
// retry zip command...
}
throw new Error(`Failed to create zip: ${error}`);
} Defensive patterns
Strategy: validation
Validate before calling
const which = await sandbox.runCommand({ cmd: 'bash', args: ['-c', 'command -v zip'] });
if (which.exitCode !== 0) throw new Error('zip is not installed in this sandbox image'); Type guard
function succeeded(r: { exitCode: number }): boolean { return r.exitCode === 0; } Try / catch
try {
const zip = await createProjectZip();
} catch (e) {
if (e.message.includes('command not found')) {
// install zip or fall back to tar
} else {
throw e;
}
} Prevention
- Bake zip (or use tar) into the sandbox image used by the app
- Capture and include stderr in thrown errors for diagnosability
- Check the project directory is non-empty before zipping
- Treat /tmp as ephemeral: create and consume the zip within one request
When it happens
Trigger: POST /api/create-zip where the in-sandbox `zip` command fails: the `zip` binary is not installed in the sandbox image, the working directory is empty or unreadable, or /tmp is not writable.
Common situations: Minimal/custom sandbox images without the zip utility; sandbox filesystem reset so the project directory is gone; permissions issues after the sandbox restarted mid-session.
Related errors
- Failed to read zip file: ${error}
- Failed to list files
- Unsupported sandbox type
- Unable to read file: ${normalizedPath}
- Failed to write file via shell: ${normalizedPath}
AI-assisted analysis of firecrawl/open-lovable@69bd93bae7 (2026-08-28).
Data as JSON: /api/errors/a73bc398aafb72dd.
Report an issue: GitHub.