{"record":{"id":"63e6d801de69ddea","repo":"affaan-m/ECC","slug":"label-destination-is-not-writable-by-the-curren","errorCode":null,"errorMessage":"${label} destination is not writable by the current user: ${candidatePath}. Fix the project ownership or permissions, then retry.","messagePattern":"(.+?) destination is not writable by the current user: (.+?)\\. Fix the project ownership or permissions, then retry\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/lib/multi-harness-setup.js","lineNumber":335,"sourceCode":"  const accessSync = dependencies.accessSync || fs.accessSync;\n  const destinationPaths = [\n    ...plan.operations.map(operation => operation.destinationPath),\n    ...(plan.installStatePath ? [plan.installStatePath] : []),\n  ];\n  const requirements = new Map();\n\n  for (const destinationPath of destinationPaths) {\n    const requirement = writableRequirement(destinationPath);\n    const existingMode = requirements.get(requirement.candidatePath) || 0;\n    requirements.set(requirement.candidatePath, existingMode | requirement.mode);\n  }\n\n  for (const [candidatePath, mode] of requirements) {\n    try {\n      accessSync(candidatePath, mode);\n    } catch (_error) {\n      const label = plan.target === 'kimi' ? 'Kimi' : 'Managed install';\n      throw new Error(\n        `${label} destination is not writable by the current user: ${candidatePath}. `\n        + 'Fix the project ownership or permissions, then retry.'\n      );\n    }\n  }\n}\n\nfunction preflightManagedPlan(plan, dependencies = {}) {\n  if (!plan || !Array.isArray(plan.operations)) {\n    throw new Error('A managed install plan with operations is required.');\n  }\n  if (typeof plan.installStatePath !== 'string' || plan.installStatePath.length === 0) {\n    throw new Error('A managed install-state path is required before preflight.');\n  }\n  const ownership = readOwnedDestinations(plan, dependencies);\n  const operations = plan.operations.map(operation => {\n    assertSafeInstallOperation(plan, operation);\n    return {","sourceCodeStart":317,"sourceCodeEnd":353,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/lib/multi-harness-setup.js#L317-L353","documentation":"assertManagedDestinationsWritable checks with accessSync that every destination path in a managed install plan is writable (or readable as required) by the current user. When any access check fails, it throws, labeling the message 'Kimi' when the plan targets the kimi harness, otherwise 'Managed install'. It is a preflight guard so installs fail fast instead of half-completing on EACCES/ENOENT during writes.","triggerScenarios":"Calling preflightManagedPlan -> assertManagedDestinationsWritable with a plan whose destinationPath does not exist, or exists but lacks the required access mode for the current user (e.g. not owner, read-only directory, root-owned path).","commonSituations":"Running the installer under a user that doesn't own the project directory (e.g. checked out by root or another developer); CI containers with reduced permissions; read-only volume mounts; a typo'd or non-existent destination path.","solutions":["Check ownership/permissions of candidatePath (ls -la) and chown or chmod so the current user has write access","Verify you are running as the intended user (sudo down/up, wrong CI user)","Confirm the path exists; create missing parent directories first","Re-run the managed install after fixing permissions"],"exampleFix":"// before\n$ whoami; ls -ld /project/.kimi\nroot root /project/.kimi   # not writable\n// after\n$ sudo chown -R $(whoami) /project/.kimi","handlingStrategy":"validation","validationCode":"const fs = require('fs');\nfunction assertWritable(path) {\n  fs.accessSync(path, fs.constants.W_OK); // throws EACCES/ENOENT before install\n}\n// call for each plan.operations destination before preflight","typeGuard":null,"tryCatchPattern":"try {\n  await result(plan);\n} catch (e) {\n  if (/not writable by the current user/.test(e.message)) {\n    console.error('Permission problem at:', e.message.match(/: ([^.]+)\\./)[1]);\n    // prompt to chown/chmod or run under correct user\n  } else throw e;\n}","preventionTips":["Run installers as the user that owns the project, not sudo","Check permissions of config dirs (.kimi, .claude, .cursor) before scripted installs","Avoid read-only container mounts for install destinations"],"tags":["filesystem","permissions","install"],"backgroundTag":"file-write-permission-denied","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}