yamadashy/repomix · error · PermissionError
Permission denied while scanning directory. Please check fol
Error message
Permission denied while scanning directory. Please check folder access permissions for your terminal app. path: ${rootDir} What it means
Repomix wraps EPERM/EACCES errors raised while globby scans directories into a PermissionError. It signals that the process lacks OS-level read permission on the directory being packed. The path reported is the root directory of the scan, not necessarily the specific unreadable subdirectory.
Source
Thrown at src/core/file/fileSearch.ts:230
logger.debug(`[stdin mode] Total include patterns after merge: ${includePatterns.length}`);
}
}
// If no include patterns at all, default to all files
if (includePatterns.length === 0) {
includePatterns = ['**/*'];
}
logger.trace('Include patterns with explicit files:', includePatterns);
logger.trace('Ignore patterns:', adjustedIgnorePatterns);
logger.trace('Ignore file patterns (for globby):', ignoreFilePatterns);
const handleGlobbyError = (error: unknown): never => {
// Handle EPERM errors specifically
const code = (error as NodeJS.ErrnoException | { code?: string })?.code;
if (code === 'EPERM' || code === 'EACCES') {
throw new PermissionError(
`Permission denied while scanning directory. Please check folder access permissions for your terminal app. path: ${rootDir}`,
rootDir,
);
}
throw error;
};
logger.debug('[globby] Starting file search...');
const globbyStartTime = Date.now();
let filePaths: string[];
let emptyDirPaths: string[] = [];
if (config.output.includeEmptyDirectories) {
// Single traversal returning both files and directories. The previous implementation
// ran globby twice with identical options (once for files, once for directories),
// which re-walks the tree and re-parses every .gitignore/.repomixignore, roughly
// doubling the discovery cost. Using `objectMode: true` lets us partition the entriesView on GitHub (pinned to f465ad9093)
Solutions
- Grant the terminal app Full Disk Access (macOS: System Settings > Privacy & Security > Full Disk Access) or access to the specific folder (Files and Folders).
- Run repomix from a directory you own, or chmod/chown the target directory so the current user can read it.
- Exclude the unreadable directory via repomix ignore configuration so globby never descends into it.
- On Linux, run under a user with read access (e.g. sudo) only if appropriate for your environment.
Example fix
// before: scanning a protected folder repomix ~/Library/Mobile\ Documents // after: pick an accessible copy or grant access first sudo chown -R "$USER" ~/protected-project # or add to repomix ignore: "protected-folder/"
Defensive patterns
Strategy: try-catch
Validate before calling
import { accessSync, constants } from 'node:fs';
try {
accessSync(rootDir, constants.R_OK | constants.X_OK);
} catch {
throw new Error(`No read permission on ${rootDir} — fix permissions or exclude this folder before packing.`);
} Type guard
const isErrnoException = (e: unknown): e is NodeJS.ErrnoException =>
typeof e === 'object' && e !== null && 'code' in e && typeof (e as { code: unknown }).code === 'string'; Try / catch
try {
await repomix.pack(...);
} catch (e) {
if (e instanceof PermissionError || (isErrnoException(e) && ['EPERM', 'EACCES'].includes(e.code))) {
console.error(`Cannot read ${rootDir}: grant the terminal Full Disk Access or exclude this folder.`);
} else throw e;
} Prevention
- Grant your terminal app Full Disk Access / Files-and-Folders permissions before scanning user-protected directories (macOS).
- Check readability with `ls -la` or fs.accessSync(rootDir, R_OK) before packing.
- Add known-protected directories to the ignore configuration.
- Run repomix as a user that owns or can read the target tree.
When it happens
Trigger: Calling searchFiles (via pack/repomix run) when globby's directory walk hits a folder the current user cannot read, causing globby to emit an error with code 'EPERM' or 'EACCES', which handleGlobbyError converts to PermissionError.
Common situations: Scanning directories protected by macOS TCC (Desktop/Documents/Downloads not granted to the terminal app), reading root-owned or other-user directories on Linux, or corporate-restricted folders.
Related errors
- Failed to copy output file to ${targetPath}: Permission deni
- Could not read the remote repository's config (${configName}
- Failed to filter files in directory ${rootDir}. Reason: ${er
- An unexpected error occurred while filtering files.
- Failed to write skill output to ${skillDir}: Permission deni
AI-assisted analysis of yamadashy/repomix@f465ad9093 (2026-08-29).
Data as JSON: /api/errors/3adc45e88cbb237e.
Report an issue: GitHub.