{"record":{"id":"dacbd8eaab542212","repo":"atuinsh/atuin","slug":"no-key-provided-and-no-existing-key-file-found-please-use","errorCode":null,"errorMessage":"No key provided and no existing key file found. Please use 'atuin key' on your other machine, or recover your key from a backup","messagePattern":"No key provided and no existing key file found\\. Please use 'atuin key' on your other machine, or recover your key from a backup","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/atuin/src/command/client/account/login.rs","lineNumber":219,"sourceCode":"        let interactive = self.interactive();\n        let mut flag_key = self.key.clone();\n\n        loop {\n            let key = match flag_key.take() {\n                Some(key) => key,\n                None => match read_user_input(\"encryption key [blank to use existing key file]\") {\n                    Some(key) => key,\n                    // Stdin is exhausted, so re-prompting would spin forever.\n                    None => bail!(\"No encryption key provided\"),\n                },\n            };\n\n            if key.is_empty() {\n                if !key_path.exists() {\n                    let msg = \"No key provided and no existing key file found. Please use 'atuin \\\n                               key' on your other machine, or recover your key from a backup\";\n                    if !interactive {\n                        bail!(msg);\n                    }\n                    println!(\"\\n{msg}\\n\");\n                    continue;\n                }\n\n                paseto_v4::Key::try_load_from_path(key_path).context(format!(\n                    \"The key in existing key file at '{}' is invalid\",\n                    key_path.to_string_lossy()\n                ))?;\n\n                return Ok(());\n            }\n\n            // The key may be EITHER base64 or a bip39 mnemonic.\n            match paseto_v4::Key::try_from_mnemonic(&key) {\n                Ok(key) => return store_key(settings, store, &key).await,\n                Err(err) if interactive => println!(\"\\n{err}. Please try again.\\n\"),\n                Err(err) => return Err(err.into()),","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/atuinsh/atuin/blob/900007c48045867e7f44b0f9bc55ad9dbe99ee0d/crates/atuin/src/command/client/account/login.rs#L201-L237","documentation":"The user provided an empty encryption key (blank at the prompt, meaning 'use existing key file'), but no key file exists at the expected key path, and the session is non-interactive so the retry prompt loop cannot continue. The key is required to decrypt history; without it login cannot proceed.","triggerScenarios":"Pressing Enter at the key prompt when no key file exists on the machine (fresh install); running login non-interactively with an empty --key while `~/.local/share/atuin/key` is absent.","commonSituations":"New laptop/workstation without the synced key file; CI runners expecting an existing key; users who deleted or never backed up their key and try to log in elsewhere.","solutions":["Provide the key from another machine: run `atuin key` there, then `atuin login --key <key>` here","Restore the key file from your backup to the expected key path before logging in with a blank key","If the key is truly lost, the old encrypted history is unrecoverable; create a new key with `atuin key gen` (losing old history)"],"exampleFix":"// before\natuin login  # blank key, no key file, non-interactive\n// after\nother$ atuin key          # copy output\natuin login --key '<key from other machine>'","handlingStrategy":"validation","validationCode":"KEY_FILE=\"${ATUIN_DATA_DIR:-$HOME/.local/share/atuin}/key\"\nif [ -z \"$ATUIN_KEY\" ] && [ ! -f \"$KEY_FILE\" ]; then\n  echo 'No key available: fetch it from another machine with `atuin key`'; exit 1\nfi","typeGuard":null,"tryCatchPattern":"if ! atuin login --key \"$ATUIN_KEY\"; then\n  echo 'login failed: missing/invalid encryption key'\nfi","preventionTips":["Back up the atuin key file securely when first created","Sync the key (secret manager) before setting up new machines","Never rely on blank-key+'existing file' behavior on fresh installs"],"tags":["encryption","key","data-loss","login"],"backgroundTag":"missing-credentials","analyzedSha":"900007c48045867e7f44b0f9bc55ad9dbe99ee0d","analyzedAt":"2026-09-19T12:52:51.491Z","contentChangedAt":"2026-09-19T12:52:51.491Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}