{"record":{"id":"5f52343e4000a946","repo":"denoland/deno","slug":"home-not-set","errorCode":null,"errorMessage":"HOME not set","messagePattern":"HOME not set","errorType":"exception","errorClass":"AnyError","httpStatus":null,"severity":"error","filePath":"cli/tools/jupyter/install.rs","lineNumber":73,"sourceCode":"    }\n    let candidate = dir.join(file_name);\n    if canonicalize_path(&candidate).is_ok_and(|c| c == target) {\n      return candidate;\n    }\n  }\n  current_exe.to_path_buf()\n}\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\"))","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/tools/jupyter/install.rs#L55-L91","documentation":"During `deno jupyter install`/`uninstall`/`status`, Deno computes the Jupyter user data dir where kernelspecs are written. On macOS it mirrors runtimelib's behavior and uses `$HOME/Library/Jupyter`; if the HOME environment variable is unset there is no way to locate the home directory and the command aborts. A test-only override (DENO_TEST_JUPYTER_PATH) short-circuits the lookup, but production use requires HOME.","triggerScenarios":"Any `deno jupyter` subcommand that calls get_user_data_dir() on macOS with HOME unset — `env -i deno jupyter install`, launchd agents without a user environment, cron jobs, or CI runners with a scrubbed environment.","commonSituations":"Minimal CI containers without a login environment; clean-room invocations with `env -i`; service managers that skip loading the user profile; broken shell rc files that unset HOME.","solutions":["Export HOME before running: `HOME=/Users/me deno jupyter install`, or fix the profile that unsets it","For services and cron, set the variable explicitly: systemd `Environment=HOME=...`, `HOME=...` in the crontab, or `ENV HOME=/root` in Dockerfiles","In wrapper scripts, default it: `export HOME=${HOME:-/tmp/deno-home}`"],"exampleFix":"# before (Dockerfile)\nRUN deno jupyter install\n\n# after\nENV HOME=/root\nRUN deno jupyter install","handlingStrategy":"validation","validationCode":"if (!Deno.env.get('HOME')) {\n  throw new Error('HOME is not set; export it before running deno jupyter install');\n}","typeGuard":"const hasHome = (): boolean => Deno.env.has('HOME');","tryCatchPattern":null,"preventionTips":["Assert required env vars in wrapper scripts before invoking deno","Set explicit HOME in CI, containers, and service definitions","Prefer login-style shells when installing kernels"],"tags":["jupyter","environment","macos","home","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"}