eyaltoledano/claude-task-master · warning
Warning: Could not generate project tree: ${error.message}
Error message
Warning: Could not generate project tree: ${error.message} What it means
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.
Source
Thrown at scripts/modules/utils/contextGatherer.js:732
try {
const tree = this._generateFileTree(this.projectRoot, 5); // Max depth 5
const finalContext = this._formatProjectTreeSection(tree, format);
const breakdown = includeTokenCounts
? {
tokens: this.countTokens(finalContext),
characters: finalContext.length,
fileCount: tree.fileCount || 0,
dirCount: tree.dirCount || 0
}
: null;
return {
context: finalContext,
breakdown: breakdown
};
} catch (error) {
console.warn(
`Warning: Could not generate project tree: ${error.message}`
);
return { context: null, breakdown: null };
}
}
/**
* Format a single file for context (used for token counting)
* @param {Object} fileData - File data object
* @param {string} format - Output format
* @returns {string} Formatted file context
*/
_formatSingleFileForContext(fileData, format) {
const header = `**File: ${fileData.path}** (${Math.round(fileData.size / 1024)}KB)`;
const content = `\`\`\`\n${fileData.content}\n\`\`\``;
return `${header}\n\n${content}`;
}
View on GitHub (pinned to c0c98d367c)
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.
Defensive patterns
Strategy: fallback
Validate before calling
import fs from 'fs';
if (!fs.existsSync(rootPath) || !fs.statSync(rootPath).isDirectory()) {
console.warn(`Project tree root invalid: ${rootPath}`);
} Try / catch
try {
const tree = generateProjectTree(rootPath);
} catch (err) {
const tree = null; // proceed without tree section
console.warn(`Tree generation skipped: ${err.message}`);
} Prevention
- 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).
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- CONFIG_ERROR
- Failed to read file ${filePath}: ${error.message}
- Failed to read ${filePath} for modification: ${err.message}
- Failed to create directory ${dirPath}: ${error.message}
- Failed to delete file ${filePath}: ${error.message}
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/511bba20dbf6ba5d.
Report an issue: GitHub.