{"record":{"id":"d4d0a9b5b2ee7ad4","repo":"vercel/turborepo","slug":"unable-to-write-gitignore","errorCode":null,"errorMessage":"Unable to write .gitignore","messagePattern":"Unable to write \\.gitignore","errorType":"exception","errorClass":"TransformError","httpStatus":null,"severity":"error","filePath":"packages/create-turbo/src/transforms/git-ignore.ts","lineNumber":24,"sourceCode":"\nconst meta = {\n  name: \"git-ignore\"\n};\n\n// eslint-disable-next-line @typescript-eslint/require-await -- must match transform function signature\nexport async function transform(args: TransformInput): TransformResult {\n  const { prompts } = args;\n  const ignorePath = path.join(prompts.root, \".gitignore\");\n  try {\n    if (!fs.existsSync(ignorePath)) {\n      fs.writeFileSync(ignorePath, DEFAULT_IGNORE);\n    } else {\n      return { result: \"not-applicable\", ...meta };\n    }\n  } catch (err) {\n    // existsSync cannot throw, so we don't need to narrow here and can\n    // assume this came from writeFileSync\n    throw new TransformError(\"Unable to write .gitignore\", {\n      transform: meta.name,\n      fatal: false\n    });\n  }\n\n  return { result: \"success\", ...meta };\n}\n","sourceCodeStart":6,"sourceCodeEnd":32,"githubUrl":"https://github.com/vercel/turborepo/blob/f9245100cf0d31d96628804ead485f6bf226e55a/packages/create-turbo/src/transforms/git-ignore.ts#L6-L32","documentation":"The create-turbo git-ignore transform writes a default .gitignore into the new project root when none exists. It throws this TransformError when fs.writeFileSync fails, for example on a permission error, a read-only filesystem, a full disk, or an invalid root path. The transform marks the error as non-fatal, so the rest of the scaffold can continue.","triggerScenarios":"Running create-turbo with a root prompt answer that points to a directory you cannot write to. The target root is read-only, out of disk space, or owned by another user. fs.writeFileSync raises EACCES, EPERM, or ENOSPC inside the try block, and the catch converts it to this TransformError.","commonSituations":"Creating a project inside a protected path such as /usr/local or C:\\Program Files. Running the CLI in a restricted CI sandbox or container with a read-only volume. A full disk during scaffolding.","solutions":["Run create-turbo again and answer the install-location prompt with a writable directory, such as one under your home folder","Check and fix permissions on the target directory: chmod u+w <dir> on macOS/Linux, or adjust folder properties on Windows","Free disk space and confirm the volume is not mounted read-only","If you need a protected path, run the terminal with elevated privileges and re-run create-turbo"],"exampleFix":"# before: project created in a read-only directory\nnpx create-turbo@latest /usr/local/my-app\n# after: create in a writable directory\nnpx create-turbo@latest ~/projects/my-app","handlingStrategy":"try-catch","validationCode":"import fs from \"node:fs\";\n\n// run before create-turbo writes into the target root\nfunction isWritableDir(dir: string): boolean {\n  try {\n    fs.accessSync(dir, fs.constants.W_OK);\n    return fs.statSync(dir).isDirectory();\n  } catch {\n    return false;\n  }\n}\n\nif (!isWritableDir(process.cwd())) {\n  throw new Error(\"Choose a writable directory before scaffolding\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  await transform(input);\n} catch (err) {\n  if (err instanceof TransformError && !err.fatal) {\n    // report and continue with remaining transforms\n    logger.warn(`skipped ${err.transform}: ${err.message}`);\n  } else {\n    throw err;\n  }\n}","preventionTips":["Scaffold only into directories your user owns, such as ~/projects","Keep free disk space on the target volume before running create-turbo","Avoid protected system paths and read-only mounts as project roots"],"tags":["create-turbo","filesystem","permissions","gitignore","scaffolding"],"backgroundTag":"permission-denied-write","analyzedSha":"f9245100cf0d31d96628804ead485f6bf226e55a","analyzedAt":"2026-08-17T10:46:15.696Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}