denoland/deno · error · AnyError
APPDATA not set
Error message
APPDATA not set
What it means
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.
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
Example fix
# before deno jupyter install # after (cmd) set APPDATA=%USERPROFILE%\AppData\Roaming deno jupyter install
Defensive patterns
Strategy: validation
Validate before calling
if (!Deno.env.get('APPDATA')) {
throw new Error('APPDATA is not set; set it before running deno jupyter install');
} Type guard
const hasAppdata = (): boolean => Deno.env.has('APPDATA'); Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
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
- HOME not set
- Not running in GitHub Actions
- vsock is not supported on this platform
- Automatic provenance is only available in GitHub Actions
- batch file arguments are invalid
AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20).
Data as JSON: /api/errors/52e175d4c4bcbaa0.
Report an issue: GitHub.
Appendix: source
Thrown at cli/tools/jupyter/install.rs:80
}
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"))
}
}
pub fn status(maybe_name: Option<&str>) -> Result<(), AnyError> {
let user_data_dir = get_user_data_dir()?;
let kernel_name = maybe_name.unwrap_or("deno");View on GitHub (pinned to 9ad36f7a2c)