{"record":{"id":"511bba20dbf6ba5d","repo":"eyaltoledano/claude-task-master","slug":"warning-could-not-generate-project-tree-error","errorCode":null,"errorMessage":"Warning: Could not generate project tree: ${error.message}","messagePattern":"Warning: Could not generate project tree: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"scripts/modules/utils/contextGatherer.js","lineNumber":732,"sourceCode":"\t\ttry {\n\t\t\tconst tree = this._generateFileTree(this.projectRoot, 5); // Max depth 5\n\t\t\tconst finalContext = this._formatProjectTreeSection(tree, format);\n\n\t\t\tconst breakdown = includeTokenCounts\n\t\t\t\t? {\n\t\t\t\t\t\ttokens: this.countTokens(finalContext),\n\t\t\t\t\t\tcharacters: finalContext.length,\n\t\t\t\t\t\tfileCount: tree.fileCount || 0,\n\t\t\t\t\t\tdirCount: tree.dirCount || 0\n\t\t\t\t\t}\n\t\t\t\t: null;\n\n\t\t\treturn {\n\t\t\t\tcontext: finalContext,\n\t\t\t\tbreakdown: breakdown\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tconsole.warn(\n\t\t\t\t`Warning: Could not generate project tree: ${error.message}`\n\t\t\t);\n\t\t\treturn { context: null, breakdown: null };\n\t\t}\n\t}\n\n\t/**\n\t * Format a single file for context (used for token counting)\n\t * @param {Object} fileData - File data object\n\t * @param {string} format - Output format\n\t * @returns {string} Formatted file context\n\t */\n\t_formatSingleFileForContext(fileData, format) {\n\t\tconst header = `**File: ${fileData.path}** (${Math.round(fileData.size / 1024)}KB)`;\n\t\tconst content = `\\`\\`\\`\\n${fileData.content}\\n\\`\\`\\``;\n\t\treturn `${header}\\n\\n${content}`;\n\t}\n","sourceCodeStart":714,"sourceCodeEnd":750,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/scripts/modules/utils/contextGatherer.js#L714-L750","documentation":"In ContextGatherer._gatherProjectTreeContext, any error while building the ASCII project tree (directory walk failures, permission errors) is caught and downgraded to this console.warn, with { context: null, breakdown: null } returned so callers skip the tree section. It signals the project tree could not be included in gathered context, not that the whole operation failed.","triggerScenarios":"Calling _gatherProjectTreeContext (via treeContextResult) when the root directory is unreadable, a subdirectory denies permission, the walker throws (e.g. too many open files, ENOENT on a directory vanishing mid-traversal), or tree-generation code throws for any reason.","commonSituations":"Running in sandboxes/CI containers with restricted read permissions; huge monorepos hitting EMFILE; directories deleted during traversal; misconfigured rootPath pointing at a non-existent directory.","solutions":["Check that the configured project root path exists and is readable.","Fix directory permissions (chmod/chown) or run with a user that can read the tree.","Reduce directory size/scope or raise the file-descriptor limit (ulimit -n) if EMFILE is the cause.","Ignore the warning if the tree is optional; downstream context still works without it."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"import fs from 'fs';\nif (!fs.existsSync(rootPath) || !fs.statSync(rootPath).isDirectory()) {\n  console.warn(`Project tree root invalid: ${rootPath}`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  const tree = generateProjectTree(rootPath);\n} catch (err) {\n  const tree = null; // proceed without tree section\n  console.warn(`Tree generation skipped: ${err.message}`);\n}","preventionTips":["Validate the project root path before invoking tree gathering.","Ensure the process user can read all project directories (CI permissions).","Raise file-descriptor limits for very large repos (ulimit -n)."],"tags":["filesystem","project-tree","warning","permissions"],"backgroundTag":"file-read-failed","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}