{"record":{"id":"9f27adac3ccebd30","repo":"wasmerio/wasmer","slug":"unable-to-determine-the-wasmer-dir-e","errorCode":null,"errorMessage":"Unable to determine the wasmer dir: {e}","messagePattern":"Unable to determine the wasmer dir: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/cli/src/config/mod.rs","lineNumber":22,"sourceCode":"use serde::{Deserialize, Serialize};\nuse std::path::{Path, PathBuf};\nuse std::sync::LazyLock;\nuse url::Url;\nuse wasmer_backend_api::WasmerClient;\n\npub static GLOBAL_CONFIG_FILE_NAME: &str = \"wasmer.toml\";\npub static DEFAULT_PROD_REGISTRY: &str = \"https://registry.wasmer.io/graphql\";\n\n/// The default value for `$WASMER_DIR`.\npub static DEFAULT_WASMER_DIR: LazyLock<PathBuf> =\n    LazyLock::new(|| match WasmerConfig::get_wasmer_dir() {\n        Ok(path) => path,\n        Err(e) => {\n            if let Some(install_prefix) = option_env!(\"WASMER_INSTALL_PREFIX\") {\n                return PathBuf::from(install_prefix);\n            }\n\n            panic!(\"Unable to determine the wasmer dir: {e}\");\n        }\n    });\n\n/// The default value for `$WASMER_DIR`.\npub static DEFAULT_WASMER_CACHE_DIR: LazyLock<PathBuf> =\n    LazyLock::new(|| DEFAULT_WASMER_DIR.join(\"cache\"));\n\n#[derive(Deserialize, Serialize, Debug, PartialEq, Eq)]\npub struct WasmerConfig {\n    /// Whether or not telemetry is enabled.\n    #[serde(default)]\n    pub telemetry_enabled: bool,\n\n    /// Whether or not updated notifications are enabled.\n    #[serde(default)]\n    pub update_notifications_enabled: bool,\n\n    /// The registry that wasmer will connect to.","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/wasmerio/wasmer/blob/8c4b9ee9d33fb2068863fbb3d328683e7e6ff7f5/lib/cli/src/config/mod.rs#L4-L40","documentation":"The CLI's DEFAULT_WASMER_DIR is resolved once at first use via dirs::data_dir (or similar). If that resolution fails and no WASMER_INSTALL_PREFIX was embedded at compile time (option_env!), the LazyLock panics with \"Unable to determine the wasmer dir\". The library needs a base directory for config/cache and cannot proceed without one.","triggerScenarios":"First access to DEFAULT_WASMER_DIR / DEFAULT_WASMER_CACHE_DIR in an environment where the XDG data dir cannot be determined (missing $HOME, no XDG_DATA_HOME, non-standard user setup), on a build compiled without the WASMER_INSTALL_PREFIX env var set.","commonSituations":"Running the wasmer CLI as a service/systemd unit with no HOME set; containers run with a stripped environment; headless CI images lacking XDG variables; custom builds where WASMER_INSTALL_PREFIX was not passed to cargo.","solutions":["Set the environment variable the resolver uses: export XDG_DATA_HOME (or HOME) to a writable path before running Wasmer.","Rebuild Wasmer with the install prefix baked in: WASMER_INSTALL_PREFIX=/usr/local cargo build ...","Check that the process user has a valid home directory (useradd -m) or run under a user with one.","Alternatively pass --dir/-C wasmer dir flags or WASMER_DIR env where the CLI supports it to bypass the default."],"exampleFix":"// before (systemd unit without HOME)\n[Service]\nExecStart=/usr/local/bin/wasmer run app.wasm\n// after\n[Service]\nEnvironment=HOME=/var/lib/wasmer\nEnvironment=XDG_DATA_HOME=/var/lib/wasmer/share\nExecStart=/usr/local/bin/wasmer run app.wasm","handlingStrategy":"validation","validationCode":"# Shell: ensure the environment can resolve a wasmer dir before launching\nif [ -z \"${HOME:-}\" ] && [ -z \"${XDG_DATA_HOME:-}\" ]; then\n  echo \"Set HOME or XDG_DATA_HOME for wasmer\" >&2\n  exit 1\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set XDG_DATA_HOME/HOME in systemd units, containers, and CI images.","Build release artifacts with WASMER_INSTALL_PREFIX set.","Create service users with home directories (useradd -m)."],"tags":["rust","panic","cli","environment","xdg","config"],"backgroundTag":"missing-env-var","analyzedSha":"8c4b9ee9d33fb2068863fbb3d328683e7e6ff7f5","analyzedAt":"2026-09-01T23:06:31.009Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}