{"record":{"id":"762e94aefe38fde7","repo":"affaan-m/ECC","slug":"localappdata-is-required-on-windows","errorCode":null,"errorMessage":"LOCALAPPDATA is required on Windows.","messagePattern":"LOCALAPPDATA is required on Windows\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/lib/nasiko-release.js","lineNumber":135,"sourceCode":"      if (response.statusCode !== 200) { response.resume(); reject(new Error(`Nasiko registry returned HTTP ${response.statusCode}.`)); return; }\n      const chunks = [];\n      let total = 0;\n      response.on('data', chunk => {\n        total += chunk.length;\n        if (total > maxBytes) request.destroy(new Error('Nasiko registry response exceeded the size limit.'));\n        else chunks.push(chunk);\n      });\n      response.on('end', () => resolve(Buffer.concat(chunks)));\n      response.on('error', reject);\n    });\n    request.setTimeout(options.timeoutMs || 15000, () => request.destroy(new Error('Nasiko registry request timed out.')));\n    request.on('error', reject);\n  });\n}\n\nfunction defaultInstallDirectory(normalized, environment = process.env, homeDirectory = os.homedir()) {\n  if (normalized.os === 'windows') {\n    if (!environment.LOCALAPPDATA) throw new Error('LOCALAPPDATA is required on Windows.');\n    return path.join(environment.LOCALAPPDATA, 'nasiko', 'bin');\n  }\n  return path.join(homeDirectory, '.local', 'bin');\n}\n\nfunction validateInstallDirectory(directory) {\n  if (typeof directory !== 'string' || directory.includes('\\0') || !path.isAbsolute(directory)) throw new Error('Nasiko install directory must be an absolute path.');\n  if (/^(?:\\\\\\\\|\\\\\\\\\\?\\\\|\\\\\\\\\\.\\\\)/.test(directory)) throw new Error('Nasiko install directory must be on a local filesystem.');\n  const resolved = path.resolve(directory);\n  if (resolved === path.parse(resolved).root) throw new Error('Nasiko cannot install directly into a filesystem root.');\n  let ancestor = resolved;\n  while (!fs.existsSync(ancestor)) {\n    const parent = path.dirname(ancestor);\n    if (parent === ancestor) throw new Error('Nasiko install directory has no resolvable filesystem ancestor.');\n    ancestor = parent;\n  }\n  const canonical = fs.realpathSync(ancestor);\n  return path.join(canonical, path.relative(ancestor, resolved));","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/affaan-m/ECC/blob/06c5e118c4d3e6c3b7f9445f973a2194c82de193/scripts/lib/nasiko-release.js#L117-L153","documentation":"defaultInstallDirectory in scripts/lib/nasiko-release.js derives the Windows install path from the LOCALAPPDATA environment variable (%LOCALAPPDATA%\\nasiko\\bin) and requires it to be set. On non-Windows this code is never reached (the function returns ~/.local/bin instead). If the process runs on Windows with LOCALAPPDATA absent, there is no safe default and the function refuses to guess.","triggerScenarios":"normalized.os === 'windows' and environment.LOCALAPPDATA is undefined/empty when defaultInstallDirectory runs. Happens in stripped CI shells, scheduled tasks/services running without a user profile, some SSH sessions into Windows, and containers that set only a handful of env vars.","commonSituations":"GitHub Actions/Jenkins Windows runners with minimal env; Git Bash or MSYS shells where env propagation drops user variables; running installers from a Windows service context; Docker Windows containers without profile initialization.","solutions":["Set LOCALAPPDATA for the process: `$env:LOCALAPPDATA = \"$env:USERPROFILE\\AppData\\Local\"` before running the installer","Or pass an explicit install directory so the default-derivation code path is skipped entirely","In CI, export LOCALAPPDATA in the job environment block"],"exampleFix":"// before: CI shell without user profile env\nawait installNasiko({ version: 'v0.1.0' }); // throws\n// after: pass an explicit directory\nawait installNasiko({\n  version: 'v0.1.0',\n  directory: path.join(os.homedir(), 'AppData', 'Local', 'nasiko', 'bin'),\n});","handlingStrategy":"validation","validationCode":"if (process.platform === 'win32' && !process.env.LOCALAPPDATA) {\n  process.env.LOCALAPPDATA = path.join(os.homedir(), 'AppData', 'Local');\n}\nawait installNasiko({ version: 'v0.1.0' });","typeGuard":"const hasLocalAppData = (env: NodeJS.ProcessEnv): env is NodeJS.ProcessEnv & { LOCALAPPDATA: string } =>\n  typeof env.LOCALAPPDATA === 'string' && env.LOCALAPPDATA.length > 0;","tryCatchPattern":"try {\n  await installNasiko({ version: 'v0.1.0' });\n} catch (error) {\n  if (/LOCALAPPDATA is required/.test(String(error.message))) {\n    // Set the env var or pass an explicit directory and retry.\n  }\n  throw error;\n}","preventionTips":["Export LOCALAPPDATA in CI job env blocks for Windows runners","Prefer passing an explicit install directory to avoid env-dependent defaults","Smoke-test installers in stripped-env shells (env -i) to catch env assumptions early"],"tags":["windows","environment","env-var","install"],"backgroundTag":"missing-env-var","analyzedSha":"06c5e118c4d3e6c3b7f9445f973a2194c82de193","analyzedAt":"2026-08-18T11:27:13.915Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}