{"record":{"id":"50e8b45c3a2380d4","repo":"yamadashy/repomix","slug":"failed-to-build-full-directory-structure-error","errorCode":null,"errorMessage":"Failed to build full directory structure: ${error instanceof Error ? error.message : String(error)}","messagePattern":"Failed to build full directory structure: (.+?)","errorType":"exception","errorClass":"RepomixError","httpStatus":null,"severity":"error","filePath":"src/core/output/outputGenerate.ts","lineNumber":397,"sourceCode":"      const allRepoFiles = Array.from(\n        new Set(\n          allFilesByRoot.flatMap((files, index) => {\n            const rootDir = rootDirs[index];\n            if (!rootDir) return [];\n            return files.map((filePath) => toOutputDisplayPath(rootDir, filePath, index));\n          }),\n        ),\n      );\n\n      // Merge in any files that weren't part of the included files so they appear in the tree\n      const includedSet = new Set(allFilePaths);\n      const additionalFiles = allRepoFiles.filter((p) => !includedSet.has(p));\n\n      directoryPathsForTree = allDirectories;\n      // additionalFiles is already disjoint from allFilePaths (filtered above), so no dedup needed\n      filePathsForTree = allFilePaths.concat(additionalFiles);\n    } catch (error) {\n      throw new RepomixError(\n        `Failed to build full directory structure: ${error instanceof Error ? error.message : String(error)}`,\n        error instanceof Error ? { cause: error } : undefined,\n      );\n    }\n  } else if (config.output.directoryStructure && config.output.includeEmptyDirectories) {\n    // Reuse pre-computed emptyDirPaths from the initial searchFiles call when available,\n    // avoiding a redundant full directory scan.\n    if (emptyDirPaths) {\n      directoryPathsForTree = emptyDirPaths;\n    } else {\n      try {\n        const results = await Promise.all(rootDirs.map((rootDir) => deps.searchFiles(rootDir, config)));\n        const merged = results.flatMap((result, index) => {\n          const rootDir = rootDirs[index];\n          if (!rootDir) return [];\n          return result.emptyDirPaths.map((emptyDirPath) => toOutputDisplayPath(rootDir, emptyDirPath, index));\n        });\n        directoryPathsForTree = [...new Set(merged)].sort();","sourceCodeStart":379,"sourceCodeEnd":415,"githubUrl":"https://github.com/yamadashy/repomix/blob/f465ad909315a22120636baf03fa5e28701a50cb/src/core/output/outputGenerate.ts#L379-L415","documentation":"When full-tree mode applies (directoryStructure enabled and full tree needed), Repomix collects all directories/files via a search call; any exception there is rethrown as a RepomixError with the original error as `cause`. It signals that enumerating the complete directory tree for the output failed, not a user config value being invalid per se.","triggerScenarios":"buildOutputGeneratorContext's full-tree branch calls the file search and it throws — e.g. an underlying filesystem error while walking directories, or an unexpected failure in the searchFiles-based full-tree enumeration.","commonSituations":"Permission-denied on directories during traversal; filesystem errors on network mounts or broken symlinks; platform-specific path issues; a regression in the directory-listing code path.","solutions":["Inspect `error.cause` (the original Error) for the real underlying filesystem failure.","Fix filesystem access: check permissions on the directories being walked.","Exclude problematic paths via `include`/`ignore` patterns in config.","Retry on transient failures (network mount glitch); report a bug if it reproduces on a normal repo."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-check walkability of the target directory\nimport fs from 'node:fs/promises';\nawait fs.access(config.cwd, fs.constants.R_OK | fs.constants.X_OK);","typeGuard":"null","tryCatchPattern":"try {\n  await pack(...);\n} catch (e) {\n  if (e instanceof RepomixError && e.message.startsWith('Failed to build full directory structure')) {\n    console.error('Underlying cause:', e.cause ?? e);\n  } else throw e;\n}","preventionTips":["Ensure the process has read/execute permission on the packed directory tree.","Avoid packing network mounts or paths with permission quirks.","Use ignore patterns for known-problematic subtrees.","Keep repomix updated to pick up filesystem-walk fixes."],"tags":["filesystem","directory-structure","wrapped-error"],"backgroundTag":"permission-denied","analyzedSha":"f465ad909315a22120636baf03fa5e28701a50cb","analyzedAt":"2026-08-29T01:27:42.024Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}