affaan-m/ECC · error · Error
LOCALAPPDATA is required on Windows.
Error message
LOCALAPPDATA is required on Windows.
What it means
On Windows, defaultInstallDirectory builds the install path from the LOCALAPPDATA environment variable. If that variable is unset or empty, the function cannot derive a safe per-user install location and throws. Non-Windows platforms use os.homedir() instead and never hit this path.
Solutions
- Set LOCALAPPDATA in the environment (typically C:\\Users\\<user>\\AppData\\Local) before running the installer.
- Pass an explicit install directory option so the default resolver is never invoked.
- If using a custom environment object in tests, include LOCALAPPDATA: 'C:\\...\\AppData\\Local'.
- Run from a normal user shell (cmd/PowerShell) that inherits the standard user environment.
Example fix
// before
await installDirectory({ os: 'windows' }); // env lacks LOCALAPPDATA
// after
process.env.LOCALAPPDATA = process.env.LOCALAPPDATA || 'C:\\Users\\me\\AppData\\Local';
await installDirectory({ os: 'windows' }); Defensive patterns
Strategy: try-catch
Validate before calling
if (process.platform === 'win32' && !process.env.LOCALAPPDATA) throw new Error('Set LOCALAPPDATA before installing nasiko.'); Type guard
const hasLocalAppData = (env) => typeof env.LOCALAPPDATA === 'string' && env.LOCALAPPDATA.length > 0;
Try / catch
try { dir = defaultInstallDirectory(normalized); } catch (err) { if (err.message.includes('LOCALAPPDATA is required')) dir = path.join(os.homedir(), 'AppData', 'Local', 'nasiko', 'bin'); else throw err; } Prevention
- Run installers from a normal user shell, not a stripped service context
- Pass an explicit install directory in CI/scripts to bypass env defaults
- Never construct minimal environment objects for install tools without standard vars
- Document LOCALAPPDATA as a prerequisite on Windows
When it happens
Trigger: Calling defaultInstallDirectory (directly or via installDirectory) with normalized.os === 'windows' while process.env (or the supplied environment object) has no LOCALAPPDATA key.
Common situations: Running the installer in a stripped-down Windows environment (service accounts, scheduled tasks, CI containers) where LOCALAPPDATA is not set; passing a custom minimal environment object; launching from a nonstandard shell that cleared the environment.
Understand the failure class
Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.
Related errors
- ${capability.reason}: ${capability.action}
- Claude Code command contains characters that are unsafe for…
- discussion is not an Announcement
- discussion number is invalid
- ECC_ITO_CLI_EXECUTABLE does not point to a readable local…
AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16).
Data as JSON: /api/errors/762e94aefe38fde7.
Report an issue: GitHub.
Appendix: source
Thrown at scripts/lib/nasiko-release.js:163
if (response.statusCode !== 200) { response.resume(); reject(new Error(`Nasiko registry returned HTTP ${response.statusCode}.`)); return; }
const chunks = [];
let total = 0;
response.on('data', chunk => {
total += chunk.length;
if (total > maxBytes) request.destroy(new Error('Nasiko registry response exceeded the size limit.'));
else chunks.push(chunk);
});
response.on('end', () => resolve(Buffer.concat(chunks)));
response.on('error', reject);
});
request.setTimeout(options.timeoutMs || 15000, () => request.destroy(new Error('Nasiko registry request timed out.')));
request.on('error', reject);
});
}
function defaultInstallDirectory(normalized, environment = process.env, homeDirectory = os.homedir()) {
if (normalized.os === 'windows') {
if (!environment.LOCALAPPDATA) throw new Error('LOCALAPPDATA is required on Windows.');
return path.join(environment.LOCALAPPDATA, 'nasiko', 'bin');
}
return path.join(homeDirectory, '.local', 'bin');
}
function validateInstallDirectory(directory) {
if (typeof directory !== 'string' || directory.includes('\0') || !path.isAbsolute(directory)) throw new Error('Nasiko install directory must be an absolute path.');
if (/^(?:\\\\|\\\\\?\\|\\\\\.\\)/.test(directory)) throw new Error('Nasiko install directory must be on a local filesystem.');
const resolved = path.resolve(directory);
if (resolved === path.parse(resolved).root) throw new Error('Nasiko cannot install directly into a filesystem root.');
let ancestor = resolved;
while (!fs.existsSync(ancestor)) {
const parent = path.dirname(ancestor);
if (parent === ancestor) throw new Error('Nasiko install directory has no resolvable filesystem ancestor.');
ancestor = parent;
}
const canonical = fs.realpathSync(ancestor);
return path.join(canonical, path.relative(ancestor, resolved));View on GitHub (pinned to 8321021c54)