yamadashy/repomix · error
Failed to create temporary directory: ${message}
Error message
Failed to create temporary directory: ${message} What it means
createToolWorkspace creates a per-invocation temp directory under the repomix tmp dir (getRepomixTmpDir()/mcp-outputs) using fs.mkdtemp. When any filesystem step fails (mkdir or mkdtemp), the error is rethrown with this message plus the OS-level cause text.
Source
Thrown at src/mcp/tools/mcpToolRuntime.ts:152
description?: string;
errorMessage?: string;
}
// Structured content for MCP tool responses with proper typing
type McpToolStructuredContent = (BaseMcpToolResponse & Record<string, unknown>) | undefined;
/**
* Creates a temporary directory for MCP tool operations
*/
export const createToolWorkspace = async (): Promise<string> => {
try {
const tmpBaseDir = path.join(getRepomixTmpDir(), 'mcp-outputs');
await fs.mkdir(tmpBaseDir, { recursive: true });
const tempDir = await fs.mkdtemp(`${tmpBaseDir}/`);
return tempDir;
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
throw new Error(`Failed to create temporary directory: ${message}`);
}
};
/**
* Generate a unique output ID
*/
export const generateOutputId = (): string => {
return crypto.randomBytes(8).toString('hex');
};
/**
* Creates a result object with metrics information for MCP tools
*/
export const formatPackToolResponse = async (
context: McpToolContext,
metrics: McpToolMetrics,
outputFilePath: string,
topFilesLen = 5,View on GitHub (pinned to f465ad9093)
Solutions
- Check permissions on the repomix tmp dir location (often under os.tmpdir()); ensure write access
- Set a writable TMPDIR environment variable to a location you can write to
- Free disk space if the cause mentions ENOSPC
- Inspect the appended OS message (e.g. EACCES, ENOSPC, EROFS) to target the root cause
Example fix
// before // TMPDIR=/nonexistent npx repomix-mcp -> EACCES/ENOENT on mkdtemp // after export TMPDIR=/tmp mkdir -p "$TMPDIR/mcp-outputs" npx repomix-mcp
Defensive patterns
Strategy: try-catch
Validate before calling
import fs from 'node:fs'; import os from 'node:os'; const base = process.env.TMPDIR || os.tmpdir(); fs.accessSync(base, fs.constants.W_OK); // throws early if not writable
Try / catch
try {
await createToolWorkspace();
} catch (e) {
if (String(e.message).startsWith('Failed to create temporary directory')) {
process.env.TMPDIR = '/tmp'; // or another writable dir, then retry
} else throw e;
} Prevention
- Ensure TMPDIR points to a writable location in containers/CI
- Monitor disk space (ENOSPC)
- Check the appended OS error code (EACCES/EROFS/ENOSPC) to diagnose
When it happens
Trigger: The temp base directory cannot be created or written because of permission denial (read-only filesystem, root-owned dir), disk full (ENOSPC), TMPDIR pointing to a nonexistent/unwritable location, or sandboxed environments blocking /tmp writes.
Common situations: Containers run with read-only tmpfs or no TMPDIR; CI runners with restricted permissions; disk quota exhausted; corporate security software blocking temp directory creation.
Related errors
- No repomix output file found in directory: ${inputPath}. Loo
- File or directory not found for path: ${inputPath}
- Failed to copy output file to ${targetPath}: Permission deni
- Failed to copy output file: ${(error as Error).message}
- Refusing to trust ${configName}: the remote repository's con
AI-assisted analysis of yamadashy/repomix@f465ad9093 (2026-08-29).
Data as JSON: /api/errors/748b083f31d14c76.
Report an issue: GitHub.