{"record":{"id":"f9d32ba62f7c3fad","repo":"eyaltoledano/claude-task-master","slug":"initialization-failed","errorCode":"INITIALIZATION_FAILED","errorMessage":"Core project initialization failed: ${error.message}","messagePattern":"Core project initialization failed: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"mcp-server/src/core/direct-functions/initialize-project.js","lineNumber":103,"sourceCode":"\t\t}\n\n\t\tlog.info(`Initializing project with options: ${JSON.stringify(options)}`);\n\t\tconst result = await initializeProject(options); // Call core logic\n\n\t\tresultData = {\n\t\t\tmessage: 'Project initialized successfully.',\n\t\t\tnext_step:\n\t\t\t\t'Now that the project is initialized, the next step is to create the tasks by parsing a PRD. This will create the tasks folder and the initial task files (tasks folder will be created when parse-prd is run). The parse-prd tool will require a prd.txt file as input (typically found in .taskmaster/docs/ directory). You can create a prd.txt file by asking the user about their idea, and then using the .taskmaster/templates/example_prd.txt file as a template to generate a prd.txt file in .taskmaster/docs/. You may skip all of this if the user already has a prd.txt file. You can THEN use the parse-prd tool to create the tasks. So: step 1 after initialization is to create a prd.txt file in .taskmaster/docs/prd.txt or confirm the user already has one. Step 2 is to use the parse-prd tool to create the tasks. Do not bother looking for tasks after initialization, just use the parse-prd tool to create the tasks after creating a prd.txt from which to parse the tasks. You do NOT need to reinitialize the project to parse-prd.',\n\t\t\t...result\n\t\t};\n\t\tsuccess = true;\n\t\tlog.info(\n\t\t\t`Project initialization completed successfully in ${targetDirectory}.`\n\t\t);\n\t} catch (error) {\n\t\tlog.error(`Core initializeProject failed: ${error.message}`);\n\t\terrorResult = {\n\t\t\tcode: 'INITIALIZATION_FAILED',\n\t\t\tmessage: `Core project initialization failed: ${error.message}`,\n\t\t\tdetails: error.stack\n\t\t};\n\t\tsuccess = false;\n\t} finally {\n\t\tdisableSilentMode();\n\t\tlog.info(`Restoring original CWD: ${originalCwd}`);\n\t\tprocess.chdir(originalCwd);\n\t}\n\n\tif (success) {\n\t\treturn { success: true, data: resultData };\n\t} else {\n\t\treturn { success: false, error: errorResult };\n\t}\n}\n","sourceCodeStart":85,"sourceCodeEnd":120,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/mcp-server/src/core/direct-functions/initialize-project.js#L85-L120","documentation":"Wrapper error for initializeProjectDirect: the core initializeProject routine threw mid-initialization, so the tool records INITIALIZATION_FAILED with the underlying message and attaches error.stack in details, marks success=false, and disables silent mode in finally. The project may be left partially initialized.","triggerScenarios":"Core initializeProject fails during scaffolding: template copy errors, directory permission denied, file-write failures, git init problems, or interactive prompts hitting non-TTY contexts.","commonSituations":"Read-only or root-owned target directory; existing .taskmaster content conflicting with templates; disk-full; running the MCP server in a sandbox that blocks git or file writes.","solutions":["Inspect details (error.stack) in the response and the server log 'Core initializeProject failed: ...' for the exact failing step","Fix filesystem permissions on the target directory and retry","Remove or back up a partially created .taskmaster directory, then re-run initialize_project","Run task-master init via CLI in the same directory to surface the interactive error directly"],"exampleFix":"// before\nawait mcp.call('initialize_project', { projectRoot: '/mnt/readonly' });\n// after\nfs.accessSync('/mnt/readonly', fs.constants.W_OK); // fail fast with a clear message\nawait mcp.call('initialize_project', { projectRoot: '/mnt/readonly' });","handlingStrategy":"try-catch","validationCode":"import fs from 'fs';\nconst root = '/target/project';\nfs.accessSync(root, fs.constants.W_OK); // writable\nconst tmDir = `${root}/.taskmaster`;\nif (fs.existsSync(tmDir)) console.warn('Existing .taskmaster found; back it up before re-initializing');","typeGuard":"function isInitializationFailed(res) {\n  return res && res.success === false && res.error?.code === 'INITIALIZATION_FAILED';\n}","tryCatchPattern":"const res = await callTool('initialize_project', { projectRoot });\nif (!res.success && res.error?.code === 'INITIALIZATION_FAILED') {\n  console.error('Init failed:', res.error.message);\n  if (res.error.details) console.error('Stack:', res.error.details); // details carries error.stack\n  // clean up partial scaffolding, then retry\n}","preventionTips":["Check disk space and write permissions before initializing","Back up or clear existing .taskmaster directories before re-init","Read res.error.details — it contains the full stack of the core failure","If MCP sandboxing blocks git/file writes, prefer the CLI init in that environment"],"tags":["mcp","initialization","error-handling"],"backgroundTag":"project-initialization-failed","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}