{"record":{"id":"52e175d4c4bcbaa0","repo":"denoland/deno","slug":"appdata-not-set","errorCode":null,"errorMessage":"APPDATA not set","messagePattern":"APPDATA not set","errorType":"exception","errorClass":"AnyError","httpStatus":null,"severity":"error","filePath":"cli/tools/jupyter/install.rs","lineNumber":80,"sourceCode":"}\n\nfn get_user_data_dir() -> Result<PathBuf, AnyError> {\n  if let Some(env_var) = std::env::var_os(TEST_ENV_VAR_NAME) {\n    return Ok(PathBuf::from(env_var));\n  }\n  // Platform-specific Jupyter user data directory (mirrors runtimelib behavior).\n  #[cfg(target_os = \"macos\")]\n  {\n    let home = std::env::var_os(\"HOME\")\n      .map(PathBuf::from)\n      .ok_or_else(|| deno_core::anyhow::anyhow!(\"HOME not set\"))?;\n    Ok(home.join(\"Library\").join(\"Jupyter\"))\n  }\n  #[cfg(target_os = \"windows\")]\n  {\n    let appdata = std::env::var_os(\"APPDATA\")\n      .map(PathBuf::from)\n      .ok_or_else(|| deno_core::anyhow::anyhow!(\"APPDATA not set\"))?;\n    Ok(appdata.join(\"jupyter\"))\n  }\n  #[cfg(not(any(target_os = \"macos\", target_os = \"windows\")))]\n  {\n    if let Some(xdg) = std::env::var_os(\"XDG_DATA_HOME\") {\n      return Ok(PathBuf::from(xdg).join(\"jupyter\"));\n    }\n    let home = std::env::var_os(\"HOME\")\n      .map(PathBuf::from)\n      .ok_or_else(|| deno_core::anyhow::anyhow!(\"HOME not set\"))?;\n    Ok(home.join(\".local\").join(\"share\").join(\"jupyter\"))\n  }\n}\n\npub fn status(maybe_name: Option<&str>) -> Result<(), AnyError> {\n  let user_data_dir = get_user_data_dir()?;\n\n  let kernel_name = maybe_name.unwrap_or(\"deno\");","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/tools/jupyter/install.rs#L62-L98","documentation":"Windows counterpart of the HOME lookup: get_user_data_dir() resolves the Jupyter user data dir to `%APPDATA%\\jupyter`. If the APPDATA environment variable is unset (it is normally maintained by the user shell), Deno cannot compute the data directory and `deno jupyter install`/`uninstall`/`status` fail before writing any kernelspec.","triggerScenarios":"Any `deno jupyter` subcommand needing the user data dir on Windows with APPDATA unset — scheduled tasks, services running as SYSTEM, stripped CI environments, or shells started without the standard user environment block.","commonSituations":"Windows Task Scheduler or service contexts where the user profile is not loaded; CI runners that clear the environment; portable/MSYS shells that do not propagate APPDATA; accounts without a roaming profile.","solutions":["Set APPDATA before the command: `set APPDATA=%USERPROFILE%\\AppData\\Roaming` then re-run","For scheduled tasks/services, enable 'Load user profile' or set the variable explicitly in the task environment","In automation, point APPDATA at a known writable directory"],"exampleFix":"# before\ndeno jupyter install\n\n# after (cmd)\nset APPDATA=%USERPROFILE%\\AppData\\Roaming\ndeno jupyter install","handlingStrategy":"validation","validationCode":"if (!Deno.env.get('APPDATA')) {\n  throw new Error('APPDATA is not set; set it before running deno jupyter install');\n}","typeGuard":"const hasAppdata = (): boolean => Deno.env.has('APPDATA');","tryCatchPattern":null,"preventionTips":["Check APPDATA in Windows automation before invoking deno jupyter","Run kernel installs from a normal user shell","Set explicit env in Task Scheduler and service definitions"],"tags":["jupyter","environment","windows","appdata","env-var"],"backgroundTag":"missing-env-var","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}