{"record":{"id":"465cf1eff972097b","repo":"eyaltoledano/claude-task-master","slug":"failed-to-copy-file-from-srcpath-to-destpath","errorCode":null,"errorMessage":"Failed to copy file from ${srcPath} to ${destPath}: ${error.message}","messagePattern":"Failed to copy file from (.+?) to (.+?): (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/tm-core/src/modules/storage/adapters/file-storage/file-operations.ts","lineNumber":271,"sourceCode":"\t */\n\tasync moveFile(oldPath: string, newPath: string): Promise<void> {\n\t\ttry {\n\t\t\tawait fs.rename(oldPath, newPath);\n\t\t} catch (error: any) {\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to move file from ${oldPath} to ${newPath}: ${error.message}`\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Copy file\n\t */\n\tasync copyFile(srcPath: string, destPath: string): Promise<void> {\n\t\ttry {\n\t\t\tawait fs.copyFile(srcPath, destPath);\n\t\t} catch (error: any) {\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to copy file from ${srcPath} to ${destPath}: ${error.message}`\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Clean up resources - releases cached steno Writers\n\t * Call this when the FileOperations instance is no longer needed\n\t * to prevent memory leaks in long-running processes.\n\t */\n\tasync cleanup(): Promise<void> {\n\t\t// Clear cached Writers to allow garbage collection\n\t\t// Note: steno Writers don't have explicit close methods;\n\t\t// they handle file descriptor cleanup internally\n\t\tthis.writers.clear();\n\t}\n}\n","sourceCodeStart":253,"sourceCodeEnd":289,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/packages/tm-core/src/modules/storage/adapters/file-storage/file-operations.ts#L253-L289","documentation":"copyFile() wraps fs.copyFile(srcPath, destPath) failures into 'Failed to copy file from <src> to <dest>: <reason>'. copyFile does not create missing destination directories and overwrites an existing destination only if it can be written; any OS error (missing source, permissions, no space) is surfaced with both paths.","triggerScenarios":"copyFile invoked when the source file does not exist (ENOENT), the source or destination directory is missing (ENOENT on path components), permissions deny read/write (EACCES), or the destination volume is full (ENOSPC).","commonSituations":"Duplicating a tag's task file before the source was ever written; copying into a tag directory that hasn't been created yet; disk quota/full disk during large copies; read-only source or destination mounts in containers.","solutions":["Confirm the source file exists at srcPath; create or restore it before copying (ENOENT is the most frequent cause).","Create the destination directory first: await fileOps.ensureDir(path.dirname(destPath)).","Fix permissions (read on source, write on destination directory) indicated by EACCES in the message.","Free disk space or quota if ENOSPC is reported, then retry the copy."],"exampleFix":"// before\nawait fileOps.copyFile('.taskmaster/tasks/master.json', '.taskmaster/tasks/feature.json');\n// ENOENT: .taskmaster/tasks/ dir missing\n// after\nawait fileOps.ensureDir('.taskmaster/tasks');\nawait fileOps.copyFile('.taskmaster/tasks/master.json', '.taskmaster/tasks/feature.json');","handlingStrategy":"validation","validationCode":"import { stat, access, constants } from 'fs/promises';\nimport path from 'path';\nexport async function canCopyFile(srcPath: string, destPath: string): Promise<boolean> {\n  try {\n    const s = await stat(srcPath);\n    if (!s.isFile()) return false;\n    await access(srcPath, constants.R_OK);\n    await access(path.dirname(destPath), constants.W_OK);\n    return true;\n  } catch { return false; }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await fileOps.copyFile(srcPath, destPath);\n} catch (err: any) {\n  if (err.message.startsWith('Failed to copy file')) {\n    console.error(`Copy failed: check source ${srcPath} exists/readable and destination dir is writable (${err.message})`);\n    throw err;\n  }\n  throw err;\n}","preventionTips":["Call ensureDir(path.dirname(destPath)) before copying.","Verify the source was created (e.g. by writeJson) before copy-based tag duplication flows.","Monitor disk space/quota; copyFile fails on ENOSPC.","Ensure read access on source and write access on destination directory in container setups."],"tags":["filesystem","copy","file-storage","io"],"backgroundTag":"file-copy-failed","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}