{"record":{"id":"2b1254dde1ece183","repo":"ethereum/go-ethereum","slug":"environment-variable-localappdata-is-undefined","errorCode":null,"errorMessage":"environment variable LocalAppData is undefined","messagePattern":"environment variable LocalAppData is undefined","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"node/defaults.go","lineNumber":118,"sourceCode":"\t\t\tif appdata == \"\" || common.IsNonEmptyDir(fallback) {\n\t\t\t\treturn fallback\n\t\t\t}\n\t\t\treturn filepath.Join(appdata, \"Ethereum\")\n\t\tdefault:\n\t\t\treturn filepath.Join(home, \".ethereum\")\n\t\t}\n\t}\n\t// As we cannot guess a stable location, return empty and handle later\n\treturn \"\"\n}\n\nfunc windowsAppData() string {\n\tv := os.Getenv(\"LOCALAPPDATA\")\n\tif v == \"\" {\n\t\t// Windows XP and below don't have LocalAppData. Crash here because\n\t\t// we don't support Windows XP and undefining the variable will cause\n\t\t// other issues.\n\t\tpanic(\"environment variable LocalAppData is undefined\")\n\t}\n\treturn v\n}\n\nfunc homeDir() string {\n\tif home := os.Getenv(\"HOME\"); home != \"\" {\n\t\treturn home\n\t}\n\tif usr, err := user.Current(); err == nil {\n\t\treturn usr.HomeDir\n\t}\n\treturn \"\"\n}\n","sourceCodeStart":100,"sourceCodeEnd":132,"githubUrl":"https://github.com/ethereum/go-ethereum/blob/6bb0588ad8e7f922e4ad5580f51265a4097af08f/node/defaults.go#L100-L132","documentation":"When computing the default data directory on Windows, geth reads LOCALAPPDATA; the comment states Windows XP lacks it and unsupported environments cause cascading issues, so the code panics if the variable is empty. It is a startup-time environment assertion, not a runtime failure.","triggerScenarios":"Running a geth-based binary on Windows where the LOCALAPPDATA environment variable is unset or empty — e.g. minimal service accounts, hardened/sandboxed environments, CI runners with stripped env, or shells started without the standard user profile.","commonSituations":"Running geth as a Windows service or scheduled task with a restricted environment; containers/WSL misconfigurations invoking Windows binaries; env cleared by orchestration tooling.","solutions":["Set LOCALAPPDATA for the process/user: 'setx LOCALAPPDATA C:\\Users\\me\\AppData\\Local' or set it in the service's environment block.","Bypass default-path computation entirely by passing an explicit --datadir D:\\chaindata.","Restore the standard user profile environment (run under a normal user session) before starting the node."],"exampleFix":"# before\ngeth --syncmode snap\n\n# after\ngeth --datadir D:\\eth-data --syncmode snap","handlingStrategy":"validation","validationCode":"func ensureAppDataEnv() error {\n    if runtime.GOOS == \"windows\" && os.Getenv(\"LOCALAPPDATA\") == \"\" {\n        return errors.New(\"LOCALAPPDATA is unset; set it or pass --datadir explicitly\")\n    }\n    return nil\n}\n// call at process start, before node.New / defaults","typeGuard":null,"tryCatchPattern":"Check the env var (or always pass --datadir) before startup; recovering after the panic leaves no datadir to use.","preventionTips":["Always pass an explicit --datadir in services, schedulers, and CI.","Verify LOCALAPPDATA exists when running under restricted Windows accounts.","Document required Windows environment variables for deployment runbooks."],"tags":["windows","environment","localappdata","datadir","startup","panic"],"backgroundTag":null,"analyzedSha":"6bb0588ad8e7f922e4ad5580f51265a4097af08f","analyzedAt":"2026-08-15T10:06:53.996Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}