jackwener/OpenCLI · error · CommandExecutionError
Could not store Midjourney ${kind} at ${filePath}: ${errorMe
Error message
Could not store Midjourney ${kind} at ${filePath}: ${errorMessage(error)} What it means
A CommandExecutionError raised when moving the downloaded file into place fails — fs.copyFile from the browser's download location to a temp path, fs.rename to the final filePath, or unlinking the original all throw. The temp file is cleaned up before rethrowing so no partial artifacts remain.
Source
Thrown at clis/midjourney/utils.js:791
} finally {
await handle.close();
}
if (actualMime !== config.mime) {
throw new CommandExecutionError(
`Midjourney ${kind} returned invalid media bytes; expected ${config.mime}, detected ${actualMime || 'unknown'}`,
);
}
if (downloaded.mime && downloaded.mime !== actualMime) {
log.warn(`Browser Bridge reported ${downloaded.mime} for ${sourcePath}; detected ${actualMime} from file bytes`);
}
const tempPath = `${filePath}.part-${process.pid}-${Date.now()}`;
try {
await fs.copyFile(sourcePath, tempPath);
await fs.rename(tempPath, filePath);
if (sourcePath !== filePath) await fs.unlink(sourcePath).catch(() => {});
} catch (error) {
await fs.unlink(tempPath).catch(() => {});
throw new CommandExecutionError(`Could not store Midjourney ${kind} at ${filePath}: ${errorMessage(error)}`);
}
return {
index,
kind,
filePath,
bytes: sourceStat.size,
url: stringOrNull(downloaded.finalUrl ?? downloaded.url),
mime: actualMime,
cached: false,
};
}
export function displayPath(filePath) {
const home = os.homedir();
return filePath.startsWith(home) ? `~${filePath.slice(home.length)}` : filePath;
}
export async function recordQuotaSnapshot(account, source = 'unknown') {View on GitHub (pinned to 49907e53dc)
Solutions
- Ensure outputDir exists and is writable before the download (the function does mkdir recursive, so check for later deletion or permission changes)
- Free disk space if ENOSPC
- Check/fix ownership and permissions on outputDir
- On Windows, wait for the browser to release the file handle before copying
- Inspect errorMessage(error) in the message for the underlying errno (EACCES/ENOENT/ENOSPC) and fix accordingly
Example fix
// before
await downloadRenderedVideo(page, jobId, i, kind, readOnlyDir);
// after
await fs.mkdir(destDir, { recursive: true });
await fs.access(destDir, fs.constants.W_OK);
await downloadRenderedVideo(page, jobId, i, kind, destDir); Defensive patterns
Strategy: try-catch
Validate before calling
await fs.promises.mkdir(destDir, { recursive: true });
await fs.promises.access(destDir, fs.constants.W_OK);
const free = await checkDiskSpace(path.parse(destDir).root);
if (free.free < 100 * 1024 * 1024) throw new Error('Less than 100MB free — downloads may fail to store'); Try / catch
try {
await downloadRenderedVideo(page, jobId, i, kind, outDir);
} catch (err) {
if (err.message.includes('Could not store Midjourney')) {
if (/ENOSPC/.test(err.message)) console.error('Disk full — free space and retry');
if (/EACCES|EPERM/.test(err.message)) console.error(`Fix permissions on ${outDir}`);
if (/ENOENT/.test(err.message)) console.error('Destination removed mid-run — recreate outputDir');
}
throw err;
} Prevention
- Create and permission-check outputDir before starting batch downloads
- Monitor free disk space for long-running export jobs
- Do not delete or move outputDir while the CLI is running
- On Windows, ensure no process locks files in the browser download directory
When it happens
Trigger: fs.copyFile or fs.rename in the try block rejects — e.g. destination directory doesn't exist, permissions deny the copy, source vanished mid-copy, or cross-device rename issues (here copy+rename so mainly EACCES/ENOENT/ENOSPC).
Common situations: outputDir was deleted or renamed between creation and storage; read-only or non-writable destination volume; disk full; the browser's temp download was cleaned before the copy; Windows file locking if the browser still holds the file open.
Related errors
- Could not read Midjourney usage snapshots: ${errorMessage(er
- File could not be read: ${path}
- Receipt file cannot be read: ${receipt}
- Could not write Midjourney image ${filePath}: ${errorMessage
- Could not write Midjourney media ${filePath}: ${errorMessage
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/20a20648eb9c5990.
Report an issue: GitHub.