denoland/deno · error · AnyError
HOME not set
Error message
HOME not set
What it means
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.
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}`
Example fix
# before (Dockerfile) RUN deno jupyter install # after ENV HOME=/root RUN deno jupyter install
Defensive patterns
Strategy: validation
Validate before calling
if (!Deno.env.get('HOME')) {
throw new Error('HOME is not set; export it before running deno jupyter install');
} Type guard
const hasHome = (): boolean => Deno.env.has('HOME'); Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
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
- APPDATA not set
- could not find ' ' .app bundle under (set via )
- Not running in GitHub Actions
- app bundle has no name
- Automatic provenance is only available in GitHub Actions
AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20).
Data as JSON: /api/errors/5f52343e4000a946.
Report an issue: GitHub.
Appendix: source
Thrown at cli/tools/jupyter/install.rs:73
}
let candidate = dir.join(file_name);
if canonicalize_path(&candidate).is_ok_and(|c| c == target) {
return candidate;
}
}
current_exe.to_path_buf()
}
fn get_user_data_dir() -> Result<PathBuf, AnyError> {
if let Some(env_var) = std::env::var_os(TEST_ENV_VAR_NAME) {
return Ok(PathBuf::from(env_var));
}
// Platform-specific Jupyter user data directory (mirrors runtimelib behavior).
#[cfg(target_os = "macos")]
{
let home = std::env::var_os("HOME")
.map(PathBuf::from)
.ok_or_else(|| deno_core::anyhow::anyhow!("HOME not set"))?;
Ok(home.join("Library").join("Jupyter"))
}
#[cfg(target_os = "windows")]
{
let appdata = std::env::var_os("APPDATA")
.map(PathBuf::from)
.ok_or_else(|| deno_core::anyhow::anyhow!("APPDATA not set"))?;
Ok(appdata.join("jupyter"))
}
#[cfg(not(any(target_os = "macos", target_os = "windows")))]
{
if let Some(xdg) = std::env::var_os("XDG_DATA_HOME") {
return Ok(PathBuf::from(xdg).join("jupyter"));
}
let home = std::env::var_os("HOME")
.map(PathBuf::from)
.ok_or_else(|| deno_core::anyhow::anyhow!("HOME not set"))?;
Ok(home.join(".local").join("share").join("jupyter"))View on GitHub (pinned to 9ad36f7a2c)